Note that using a fixed IV is a bad practice. It should be random. It is
ok to include it with the cipher text (perhaps as the first X bytes of the
encrypted data), but you really do want it to be random.
Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net --
[quoted text, click to view] "Steve Telford" <SteveTelford@discussions.microsoft.com> wrote in message
news:9B72828F-B1D1-4B58-A6C0-8A3C1843FB01@microsoft.com...
> Thank you very much Pieter.
> Sometimes the simplest answers are staring you right in the face! I spent
> hours looking at this, and still missed it!!
>
> "Pieter Philippaerts" wrote:
>
>> "Steve Telford" <SteveTelford@discussions.microsoft.com> wrote
>> > public static string decrypt(string sCypherText)
>> > {
>> > if (sCypherText != "")
>> > {
>> > DESCryptoServiceProvider dcsp = new
>> > DESCryptoServiceProvider();
>> >
>> > byte[] buffer = Convert.FromBase64String(sCypherText);
>> > MemoryStream ms = new MemoryStream();
>> > CryptoStream cs = new CryptoStream(ms,
>> > dcsp.CreateDecryptor(KEY_64, IV_64),
>> > CryptoStreamMode.Read);
>> > StreamReader sr = new StreamReader(cs);
>> >
>> > return sr.ReadToEnd();
>> > }
>> > return "";
>> > }
>> > }
>>
>> In the above method you decode the Base64 string into a byte array, and
>> then
>> do nothing with the result (buffer isn't used anymore after the call to
>> FromBase64String). You probably forgot to initialize the MemoryStream
>> with
>> the buffer..?
>>
>> Regards,
>> Pieter Philippaerts
>>
>>
>>