I have manage to solve my problem but I have to use base32encoder and
base32decoder.
Thanks for all who helped me.
btw, Patrick appending a NULL character did not help solve the
problem. I got back the same error as before.
On May 11, 11:18 pm, Patrick <[EMAIL PROTECTED]> wrote:
> I think I had something similar, you may need to encypher the NULL
> terminating character on the end of the string(or add it on when you
> decypher)
>
> On May 10, 9:32 am, eva2002 <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > i am new to crypto++. I am currently trying to encrypt then decrypt
> > portion of a file. However, I have encounter some problems and require
> > some help.
>
> > code:
> > CIPHER Algo = AES
> > CIPHER_MODE = CTR
>
> > // encryption
> > while(counter < TOTALBLOCK)
> > {
> > infile.read(plainText,INSIZE);
> > CryptoPP::CIPHER_MODE<CryptoPP::CIPHER>::Encryption Encryptor(key,
> > sizeof(key), iv);
> > CryptoPP::StringSource(plainText, true, new
> > CryptoPP::StreamTransformationFilter(Encryptor, new
> > CryptoPP::StringSink(CipherText)));
> > std::strcpy(tempText1, CipherText.c_str());
> > std::cout << counter+1 << " encrypted : " << CipherText << " | " <<
> > CipherText.length() << std::endl;
> > outfile.write(tempText1,OUTSIZE);
> > counter++;
>
> > //clear temp variable content
>
> > }
>
> > //decryption
> > counter = 0;
>
> > while(counter < TOTALBLOCK)
> > {
> > in.read(tempText1,OUTSIZE);
> > CipherText = tempText1;
> > CryptoPP::CIPHER_MODE<CryptoPP::CIPHER>::Decryption Decryptor(key,
> > sizeof(key), iv);
> > CryptoPP::StringSource(CipherText, true, new
> > CryptoPP::StreamTransformationFilter(Decryptor, new
> > CryptoPP::StringSink(RecoverText)));
> > std::cout << counter+1 << " decrypted : " << RecoverText << " | " <<
> > RecoverText.length() << std::endl;
> > std::strcpy(tempText, RecoverText.c_str());
> > out.write(tempText,INSIZE);
> > counter++;
>
> > //clear temp variable content
>
> > }
>
> > scenario 1:
>
> > file content -
> > 1234567980ABCDEFGHIJ (x5 without any newline) (20 bytes per set)
> > output is fine
>
> > scenario 2:
>
> > file content -
> > 1234567980ABCDEFGHIJ
> > 1234567980ABCDEFGHIJ
> > 1234567980ABCDEFGHIJ
> > 1234567980ABCDEFGHIJ
> > 1234567980ABCDEFGHIJ
>
> > output
> > 1234567890ABCDEFGHIJ
> > 1234567890ABCDEFGHIJ
> > 1234567890ABCDEFGHIJ
> > 1234567890ABCDEFGHIJ
> > 123 FG7890ABCDEFGHIJxÔ´ F
>
> > can anyone tell me what's wrong?
>
> > If I encrypt and decrypt scenario file by feeding in the whole file
> > i.e. using filesource, filesink, it works fine.
--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---