Friday, October 22, 2010

Don't Roundtrip Ciphertext Via a String Encoding - .NET Security Blog - Site Home - MSDN Blogs

Don't Roundtrip Ciphertext Via a String Encoding - .NET Security Blog - Site Home - MSDN Blogs: "Instead if you want to convert the ciphertext into a string, use Base64 encoding. Replacing the two conversion lines with:

byte[] encrypted = memoryStream.ToArray();
return Convert.ToBase64String(encrypted);


byte[] rawData = Convert.FromBase64String(data);

Results in code that works every time, since base 64 encoding is guaranteed to be able to accurately represent any input byte sequence.

- Sent using Google Toolbar"

No comments: