I need an example of string encryption (in C++ -> I\'m working on linux-Ubuntu) with aes-cbc256 and a padding: PKCS7 Please help.
For the following code how ca
look also at my answer to this question
I suggest checking out cryptopp. Here's a code sample:
CryptoPP::CBC_Mode::Encryption encryptor;
byte* key;
size_t keylen;
// ... acquire key
encryptor.SetKey( key, keylen );
std::string input;
std::string result;
// read input ...
StringSource( input, true,
new StreamTransformationFilter( encryptor, new StringSink( result ),
StreamTransformationFilter::PKCS_PADDING));
The values for padding mode in StreamTransformationFilter can be:
BlockPaddingScheme {
NO_PADDING, ZEROS_PADDING, PKCS_PADDING, ONE_AND_ZEROS_PADDING,
DEFAULT_PADDING
}
EDIT: replaced the padding mode in the sample to pkcs