[Botan-devel] Botan: Decoding error: AES/CBC/PKCS7

Jawwad Shamsi jshamsi at cs.wayne.edu
Thu Apr 14 02:35:34 EDT 2005

I have two questions

I am trying to write a program which has two parts
1) Part 1 reads plain text from file, encrypts it and writes the cipher to
the output file
2) Part 2 reads the cipher text from file , decrypts it and writes the
plain text to another output file .

The program uses symmeric key, However I am unable to get the 2nd part
working and getting Decoding error: AES/CBC/PKCS7

Also, I was wondering if it is possible to encrypt a C++ object like
structure ?

Following is the program for Q1,

Thanks a lot

#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(32);
	InitializationVector iv(16);
	cout <<" key is "<< key.as_string()<<endl;
	Pipe pipe(get_cipher("AES/CBC/PKCS7", key,iv, ENCRYPTION), new

 std::ifstream infile("plaintext1.txt");
       std::ofstream outfile("ciphered.txt");

      infile >> pipe;
       outfile << pipe;

cout <<" finished encryption"<< endl;

	Pipe pipe2(get_cipher("AES/CBC/PKCS7", key, iv, DECRYPTION));

 	std::ofstream outfile2("plaintext.txt");
       std::ifstream infile2("ciphered.txt");

      infile2 >> pipe2;
       outfile2 << pipe2;

	 catch (std::exception &e) {
       std::cerr << "exc caught: " << e.what() << std::endl;
	return 0;

More information about the botan-devel mailing list