#include <iostream.h>
#include "aes.h"
#include "modes.h"
#include "files.h"
#include "osrng.h"
#include "pch.h"
#include "files.h"
#include "hex.h"
#include "modes.h"
#include "cbcmac.h"
#include "dmac.h"
#include "idea.h"
#include "des.h"
#include "rc2.h"
#include "arc4.h"
#include "rc5.h"
#include "blowfish.h"
#include "diamond.h"
#include "wake.h"
#include "3way.h"
#include "safer.h"
#include "gost.h"
#include "shark.h"
#include "cast.h"
#include "square.h"
#include "seal.h"
#include "rc6.h"
#include "mars.h"
#include "rijndael.h"
#include "twofish.h"
#include "serpent.h"
#include "skipjack.h"
#include "osrng.h"
#include "zdeflate.h"
#include <stdlib.h>
#include <time.h>
#include <memory>
#include <iostream>
#include <iomanip>
#include "validate.h"
std::string enc(byte *key,byte *iv,std::string strPlaintext2) {
using namespace CryptoPP;
std::string strEncrypted;
CBC_Mode<AES>::Encryption cbcEncryption(key, AES::DEFAULT_KEYLENGTH, iv);
StreamTransformationFilter cbcEncryptor(cbcEncryption, new StringSink(strEncrypted));
cbcEncryptor.Put((const unsigned char *)strPlaintext2.c_str(), strPlaintext2.size());
cbcEncryptor.MessageEnd();
return strEncrypted;
}
std::string dec(byte *key,byte *iv,std::string input) {
using namespace CryptoPP;
std::string strDecrypt;
CBC_Mode<AES >::Decryption cbcDecryption(key, AES::DEFAULT_KEYLENGTH, iv);
StreamTransformationFilter cbcDecryptor(cbcDecryption, new
StringSink(strDecrypt));
cbcDecryptor.Put((const unsigned char *)input.c_str(),
input.size());
cbcDecryptor.MessageEnd();
return strDecrypt;
}
int main(int argc, char *argv[])
{
using namespace CryptoPP;
using namespace CryptoPP;
char plaintext[1024];
AutoSeededRandomPool rng;
byte key[256], iv[256];
rng.GenerateBlock(key, 256);
rng.GenerateBlock(iv, 256);
FILE *stream;
char line[1000000];
if( (stream = fopen( "fgets.c", "r" )) != NULL )
{
if( fgets( line, 1000, stream ) == NULL)
// printf( "fgets error\n" );
// else
// printf( "%s", line);
fclose( stream );
}
std::string strEncrypted, strCiphertext1, strCiphertext2;
std::string strPlaintext1 , strPlaintext2 = "Second string";
strPlaintext1 = line;
strEncrypted = enc(key,iv,strPlaintext1);
cout << "check out" << strEncrypted.c_str() <<endl ;
strCiphertext2 = dec(key,iv,strEncrypted);
cout << strCiphertext2.c_str() << endl;
cout << strCiphertext2.length() << endl;
}
Julia Smith <[EMAIL PROTECTED]> wrote:
Is there sample code for this? Key generation is what I have no idea how to get at.
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
