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

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


Hello
I have two questions

Q1.
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

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



Following is the program for Q1,

Thanks a lot
Jawwad

******************************************************
#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
Base64_Encoder);

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

       pipe.start_msg();
      infile >> pipe;
      pipe.end_msg();
       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");

       pipe2.start_msg();
      infile2 >> pipe2;
      pipe2.end_msg();
       outfile2 << pipe2;


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





More information about the botan-devel mailing list