string lInputText;
string lResultText;
...
byte lKey[TEA::DEFAULT_KEYLENGTH];
byte lIVector[TEA::BLOCKSIZE];
StringSource(reinterpret_cast<const char*>(fEncryptionKey.data()), true,
new HashFilter(*(new SHA256), new ArraySink(lKey, TEA::DEFAULT_KEYLENGTH))
);
memset(lIVector, 0x00, TEA::BLOCKSIZE);
CBC_Mode<TEA>::Encryption Encryptor(lKey, sizeof(lKey), lIVector);
StringSource(lInputText, true,
new StreamTransformationFilter(Encryptor,
new HexEncoder(new StringSink(lResultText)))
);
string lInputText;
string lResultText;
QByteArray fEncryptionKey;
...
byte lKey[TEA::DEFAULT_KEYLENGTH];
byte lIVector[TEA::BLOCKSIZE];
StringSource(reinterpret_cast<const char*>(fEncryptionKey.data()), true,
new HashFilter(*(new SHA256), new ArraySink(lKey, TEA::DEFAULT_KEYLENGTH))
);
memset(lIVector, 0x00, TEA::BLOCKSIZE);
CBC_Mode<TEA>::Encryption Encryptor(lKey, sizeof(lKey), lIVector);
StringSource(lInputText, true,
new StreamTransformationFilter(Encryptor,
new HexEncoder(new StringSink(lResultText)))
);
To copy to clipboard, switch view to plain text mode
Bookmarks