Re: Stream encryption not working
From: Alek Davis (alek_DOT_davis_AT_intel_DOT_com)
Date: 03/27/03
- Next message: Marcelo: "CRL"
- Previous message: Alek Davis: "Re: Encrypting byte array"
- In reply to: pguan: "Stream encryption not working"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Alek Davis" <alek_DOT_davis_AT_intel_DOT_com> Date: Thu, 27 Mar 2003 09:56:43 -0800
Peng,
Here is another sample: http://www.obviex.com/samples/encryption.aspx. It
uses Rijndael algorithm instead of RC2, but the logic should be the same).
In one of the other posts, someone mentioned this sample (Triple-DES):
http://www.aspemporium.com/aspEmporium/cshrp/howtos/howto.asp?hid=10. You
can also try MSDN sample describing how to build an encryption library. I
think it has RC2 example (although, I am not sure, maybe it is RC4). Check
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/ht
ml/SecNetHT10.asp (or http://tinyurl.com/72li).
-- Alek
"pguan" <peng.guan@bljc.com> wrote in message
news:473101c2f31e$46ed23f0$3401280a@phx.gbl...
> I try to encrypt a string using the code below. But the
> print out is still "encrypt me", where I expected some
> scrambled data
> *******************************************
>
>
> Dim strContent As String = "encrypt me"
> Dim ue As New UnicodeEncoding()
> 'convert string to byte array
> Dim msgbytes As Byte() = ue.GetBytes
> (strContent)
> 'create mem stream from the byte array
> Dim streamMem As MemoryStream = New
> MemoryStream(msgbytes)
> Dim RC2 As RC2CryptoServiceProvider = New
> RC2CryptoServiceProvider()
> "Encrypt stream
> Dim yy As CryptoStream = New CryptoStream
> (streamMem, RC2.CreateEncryptor(RC2.Key, RC2.IV),
> CryptoStreamMode.Write)
>
> 'read the encrypted data
> Dim reader As New StreamReader(streamMem)
> Console.WriteLine(reader.ReadLine()
- Next message: Marcelo: "CRL"
- Previous message: Alek Davis: "Re: Encrypting byte array"
- In reply to: pguan: "Stream encryption not working"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]