17 QByteArray buffer(in);
18 for(
int i = 0; i < number; ++i)
20 buffer.append(number);
22 QByteArray result(buffer.size(),
'0');
32 return hex ? result.toHex() : result.toBase64();
43 const QByteArray &buffer = hex ? QByteArray::fromHex(in) : QByteArray::fromBase64(in);
44 QByteArray result(buffer.length(),
'0');
54 const char padding = result.at(result.size() - 1);
55 return result.left(result.size() - padding);
66 const int length = in.length();
71 char *input =
new char[total + 1]();
73 memset(input, number, total);
74 memcpy(input, in.data(), length);
79 const QByteArray result((
const char *)buffer, total);
80 return hex ? result.toHex() : result.toBase64();
92 const QByteArray &input = hex ? QByteArray::fromHex(in) : QByteArray::fromBase64(in);
94 AES_cbc_encrypt((
const unsigned char *)input.data(), (
unsigned char *)buffer, input.length(), &aes, (
unsigned char *)iv.data(),
AES_DECRYPT);
96 QByteArray result(buffer);
97 const char padding = result.at(result.size() - 1);
98 return result.left(result.size() - padding);
static constexpr int DATA_CACHE_SIZE
int AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key)
Expand the cipher key into the decryption key schedule.
int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key)
Expand the cipher key into the encryption key schedule.
static constexpr wchar_t key[]
QByteArray encryptECB(const QByteArray &in, const QByteArray &key, bool hex=false)
QByteArray decryptECB(const QByteArray &in, const QByteArray &key, bool hex=false)
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key, const int enc)
QByteArray decryptCBC(const QByteArray &in, const QByteArray &key, const QByteArray &iv, bool hex=false)
QByteArray encryptCBC(const QByteArray &in, const QByteArray &key, const QByteArray &iv, bool hex=false)
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, const int enc)