Re: Can't get basic encryption to work
- From: Dominick Baier <dbaier@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 6 Mar 2007 07:24:59 +0000 (UTC)
just some ideas:
try to flush the streamwriter first...
if that doesn't help, try to position the memstream to the beginning (using ..Seek)
-----
Dominick Baier (http://www.leastprivilege.com)
Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
I am just trying to encrypt some data and am pretty much copying the
code that the MSDN docs have for the RijndaelManaged class:
RijndaelManaged cryptAlg = null;
MemoryStream mStream = null;
CryptoStream cStream = null;
StreamWriter sWriter = null;
try
{
cryptAlg = new RijndaelManaged();
ICryptoTransform encryptor = cryptAlg.CreateEncryptor(cryptAlg.Key,
cryptAlg.IV);
mStream = new MemoryStream();
cStream = new CryptoStream(mStream, encryptor,
CryptoStreamMode.Write);
sWriter = new StreamWriter(cStream);
sWriter.Write(dataToEncrypt); // encrypt a string
byte[] hookie = mStream.ToArray(); ***GETTING NOTHING HERE***
}
The MemoryStream mStream has nothing in it after this. The Length is
0 and I get no data from it. Since I just copied the code from the
MSDN example, I can't figure out what is wrong. I am just doing this
in a console app right now. So nothing fancy here.
Please help!
Thanks!
.
- Prev by Date: Impersonate Domain User from workgroup
- Next by Date: Re: Can't get basic encryption to work
- Previous by thread: Impersonate Domain User from workgroup
- Next by thread: Re: Can't get basic encryption to work
- Index(es):