Hi there.
I'm having some "problems" for quite some time now with Crypto++.
There are two issues i want to raise: 

1.I encrypt with AES a plain text , i dump the ciphertext in a file and then
i try to read the file intro a string.
I used to read the file like that:

//this would give me the correct file size
long fileLength = FileMessageSize(finName);

ifstream ifs(finName.c_str(),ios_base::binary);
ifs.read(buf,fileLength);
ifs.close();

The problem is that because the file contains weird characters after the
encryption , it actually reads until it finds end of file (or 00 i think -
in hex) (->i debuged my program and seen it stops when encountering 00)
Behaves the same if using fread().
Thus i changed to C style reading which works fine:
unsigned i = 0;
while(!feof(f))
{
        fscanf(f, "%c", &str[i]);
        i++;
}

(Said all the above for others that might encounter the same problem and as
a preamble for the next part)

2.I wanted to hex encode the text after i encrypted it so i could keep it in
a "nicer" format.
So i encrypt the plain text , and then i encode with this:

string HexEncode(string in)
{
        string result;

        StringSource(in.c_str(), true, new HexEncoder(new StringSink(result)));

        return result;
}

The problem is that the encrypted text has 17000 bytes (a test string i'm
using), but the encoding of the encrypted string has only 200 , something
like that . And my guess is that HexEncoder(new StringSink(result)) works
with buffering functions and it behaves similar to what I described at point
1, only that here it probably finds '\0' when reading those weird characters
and he thinks the string terminates there and stops.

I just wanted to point out these issues , maybe you'll find them important
(the second one) - if not , at least people that encounter the same problem
will know why it happens.

Cheers

-- 
View this message in context: 
http://www.nabble.com/Encryption-and-Encoding-conflict--tp21652293p21652293.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
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