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;
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;
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;
125 char*
input =
nullptr;
126 size_t inputSize = 0;
128 throwException(
"Input provided is not a valid base64 string.",
"Cipher::b64decrypt");
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)
ret
prodAgent to be discontinued
void throwException(const std::string &message, const std::string &methodName)
static std::string const input
void free(void *ptr) noexcept
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)
void * malloc(size_t size) noexcept
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)