[Botan-devel] cipher + hex_decoder/encoder
Larrson
larrson at ecdlp.org
Sat Jul 15 16:57:23 EDT 2006
Hi all,
In the following program i can't understood, why encrypted message is
twice longer as should be. The first part is ok,
E353779C1079AEB82708942DBE77181A, but from is
B97C825E1C785146542D396941BCE55D i don't know.
Output:
Key = 06A9214036B8A15B512E03D534120006
IV = 3DAFBA429D9EB430B422DA802C9FAC41
Input = Single block msg
Encrypted = E353779C1079AEB82708942DBE77181AB97C825E1C785146542D396941BCE55D
Decrypted = Single block msg
Regards,
Thomas
********************************************************************
#include <botan/botan.h>
#include <botan/base.h>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
using namespace Botan;
int main()
{
try
{
Botan::LibraryInitializer init;
SymmetricKey key("06a9214036b8a15b512e03d534120006");
InitializationVector iv ("3dafba429d9eb430b422da802c9fac41");
string msg = "Single block msg";
cout << " Key = "<< key.as_string() << endl;
cout << " IV = "<< iv.as_string() << endl;
cout << " Input = "<< msg << endl;
Pipe enc(get_cipher("AES/CBC/PKCS7", key,iv, ENCRYPTION), new
Hex_Encoder);
Pipe dec(new Hex_Decoder, get_cipher("AES/CBC/PKCS7", key, iv,
DECRYPTION));
enc.process_msg(msg);
string encrypted = enc.read_all_as_string();
cout << "Encrypted = " << encrypted << endl;
dec.process_msg(encrypted);
string decrypted = dec.read_all_as_string();
cout << "Decrypted = " << decrypted << endl;
}
catch (std::exception &e) {
std::cerr << "exc caught: " << e.what() << std::endl;
}
return 0;
}
More information about the botan-devel
mailing list