> Encrypt("in.txt", "chiper.dat", "123", "3124");
> Decrypt("chiper.dat", "out.txt", "123", "3124");
Incorrect sizes

>  byte biv[AES::DEFAULT_KEYLENGTH];
Incorrct size, but you got lucky.

Jeff

On 4/11/09, anno <[email protected]> wrote:
>
> Ok here is some code that someone can test it:
>
> #include "mainwindow.h"
>
> #include "ui_mainwindow.h"
>
>
>
>
>
>
> //
> *********************************************************************************************
>
>
>
> void MainWindow::Encrypt(string in_filename,
>
>                                                                        string 
> out_filename,
>
>                                                                        string 
> key, string iv) {
>
>
>
>        try {
>
>
>
>                StreamTransformationFilter *encryptor;
>
>
>
>                byte bkey[AES::DEFAULT_KEYLENGTH];
>
>                byte biv[AES::DEFAULT_KEYLENGTH];
>
>
>
>                memcpy(bkey, key.c_str(), AES::DEFAULT_KEYLENGTH);
>
>                memcpy(biv, iv.c_str(), AES::DEFAULT_KEYLENGTH);
>
>
>
>                CBC_Mode<AES>::Encryption cbc_decryptor(bkey, sizeof(bkey), 
> biv);
>
>
>
>                encryptor = new StreamTransformationFilter(cbc_decryptor, new
> FileSink(out_filename.c_str()));
>
>
>
>                FileSource file(in_filename.c_str(), true, encryptor);
>
>
>
>
>
>        }
>
>        catch(CryptoPP::Exception &e) {
>
>
>
>        }
>
> }
>
>
>
> void MainWindow::Decrypt(string in_filename,
>
>                                                                        string 
> out_filename,
>
>                                                                        string 
> key, string iv) {
>
>
>
>        try {
>
>
>
>                StreamTransformationFilter *decryptor;
>
>
>
>                byte bkey[AES::DEFAULT_KEYLENGTH];
>
>                byte biv[AES::DEFAULT_KEYLENGTH];
>
>
>
>                memcpy(bkey, key.c_str(), AES::DEFAULT_KEYLENGTH);
>
>                memcpy(biv, iv.c_str(), AES::DEFAULT_KEYLENGTH);
>
>
>
>                CBC_Mode<AES>::Decryption cbc_decryptor(bkey, sizeof(bkey), 
> biv);
>
>
>
>                decryptor = new StreamTransformationFilter(cbc_decryptor, new
> FileSink(out_filename.c_str()));
>
>
>
>                FileSource file(in_filename.c_str(), true, decryptor);
>
>
>
>        }
>
>        catch(CryptoPP::Exception &e) {
>
>
>
>
>
>        }
>
>
>
> }
>
>
>
> MainWindow::MainWindow(QWidget *parent)
>
>    : QMainWindow(parent), ui(new Ui::MainWindowClass)
>
> {
>
>                ui->setupUi(this);
>
>
>
>                Encrypt("in.txt", "chiper.dat", "123", "3124");
>
>                Decrypt("chiper.dat", "out.txt", "123", "3124");
>
>
>
>
> }
>
>
>
> MainWindow::~MainWindow()
>
> {
>
>    delete ui;
>
> }
>
>
>
> //
> *********************************************************************************************
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to