11 char*
k =
const_cast<char*
>(key.c_str());
24 unsigned int j =
sizeof(
uInt32);
26 unsigned int output_size = 0;
33 for (
unsigned int i = 0;
i < input_size;
i += (j * 2)) {
34 output_size =
i + 2 *
j;
36 output = (
unsigned char*)malloc(output_size);
37 memset(output, 0, output_size);
39 for (
unsigned int i = 0;
i < input_size;
i += (j * 2)) {
43 if (input_size >
i + j) {
45 if (input_size >
i + 2 * j) {
48 nr = input_size -
i -
j;
55 memcpy(&L, input +
i, nl);
57 memcpy(&R, input +
i + j, nr);
63 memcpy(output +
i, &L, j);
64 memcpy(output +
i + j, &R, j);
75 return bf_process_alloc(reinterpret_cast<const unsigned char*>(input.c_str()), input.size(),
output,
false);
82 unsigned char*
out =
nullptr;
83 size_t outSize = bf_process_alloc(input, inputSize, out,
true);
85 for (i = 0; i < outSize; i++) {
90 char* sout =
reinterpret_cast<char*
>(
out);
94 for (soutSize = 0; soutSize < outSize; soutSize++)
95 if (out[soutSize] == 0)
98 if (soutSize < outSize) {
112 unsigned char*
out =
nullptr;
113 size_t outSize = bf_process_alloc(reinterpret_cast<const unsigned char*>(input.c_str()), input.size(),
out,
false);
114 char* b64out =
nullptr;
115 size_t b64size =
base64_encode_alloc(reinterpret_cast<const char*>(out), outSize, &b64out);
125 char*
input =
nullptr;
126 size_t inputSize = 0;
128 throwException(
"Input provided is not a valid base64 string.",
"Cipher::b64decrypt");
130 std::string ret = decrypt(reinterpret_cast<const unsigned char*>(input), inputSize);
tuple ret
prodAgent to be discontinued
void Blowfish_Encrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr)
void Blowfish_Decrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr)
void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen)
void throwException(const std::string &message, const std::string &methodName)
static std::string const input
tuple key
prepare the HTCondor submission files and eventually submit them
size_t encrypt(const std::string &input, unsigned char *&output)
size_t base64_encode_alloc(const char *in, size_t inlen, char **out)
Cipher(const std::string &key)
#define base64_decode_alloc(in, inlen, out, outlen)
size_t bf_process_alloc(const unsigned char *input, size_t input_size, unsigned char *&output, bool decrypt=false)
std::string b64encrypt(const std::string &input)
std::string decrypt(const unsigned char *input, size_t inputSize)
std::string b64decrypt(const std::string &input)