Re: How to decrypt a string?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Thu, 8 Feb 2007 19:27:48 -0000
Kevin Spencer <unclechutney@xxxxxxxxxxxx> wrote:
Not at all. The MemoryStream already contains a string. In essence, you are
converting a string to another string.
No. Encryption works on binary data, and it's not safe to treat
arbitrary binary data as if it were valid text data.
The OP is quite right to convert the encrypted bytes into a string
using Base64 and then convert the Base64 data back into bytes before
decryption.
What he's doing wrong is using StreamWriter.Write(bytes) instead of
just writing the converted data directly into the MemoryStream.
The encryption is:
Plaintext String -> Encrypted bytes -> Base64
The decrypion should thus be:
Base64 -> Encrypted bytes -> Plaintext String
Currently it's
Base64 -> Encrypted bytes -> ToString() -> Plaintext String
The call to ToString() is in the StreamWriter.Write(object) call.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: How to decrypt a string?
- From: Kevin Spencer
- Re: How to decrypt a string?
- References:
- How to decrypt a string?
- From: Ralph Moritz
- Re: How to decrypt a string?
- From: Ralph Moritz
- How to decrypt a string?
- Prev by Date: Re: Controlling Windows Firewall from .Net
- Next by Date: Re: Running Applications
- Previous by thread: Re: How to decrypt a string?
- Next by thread: Re: How to decrypt a string?
- Index(es):
Relevant Pages
|
Loading