Re: Stream encryption not working
From: Ben Lowery (msnews@blowery.org)
Date: 03/25/03
- Previous message: pguan: "Stream encryption not working"
- In reply to: pguan: "Stream encryption not working"
- Next in thread: Alek Davis: "Re: Stream encryption not working"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Ben Lowery" <msnews@blowery.org> Date: Tue, 25 Mar 2003 17:51:31 -0500
it's a little more involved than that. check out this article for the whole
deal:
it has some examples that should do what you want.
[1] originally
http://www.ondotnet.com/pub/a/dotnet/2003/02/10/dotnetcryto.html
"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()
- Previous message: pguan: "Stream encryption not working"
- In reply to: pguan: "Stream encryption not working"
- Next in thread: Alek Davis: "Re: Stream encryption not working"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]