CryptoStream

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If this is not the right new group for a question about CryptoStream please
point me to the right place. I have looked at several vb.net code examples
for Rijndael encryption but have a couple of questions. My questions concern
the byte arrays for key and IV.

First, do I provide the key string or is that generated by crypto class?
Second, what is the IV array for and how do I know how to set that or is it
set automatically by the crypto class.

I am looking for some qualitative info here so I can understand what the
pieces are supposed to do.

Thanks,
Fred Herring
 
Fred Herring said:
If this is not the right new group for a question about CryptoStream please
point me to the right place.

I'd suggest either microsoft.public.dotnet.framework or
microsoft.public.dotnet.general - it's certainly not a Windows Forms
question. Anyway:
I have looked at several vb.net code examples
for Rijndael encryption but have a couple of questions. My questions concern
the byte arrays for key and IV.
First, do I provide the key string or is that generated by crypto class?

You can ask it to generate the key if you want, but obviously you need
to use the same one for encryption and decryption. You can use the
LegalKeySizes property to find out what the valid key sizes are - note
that a key isn't a string, but a byte array. If you have a password or
pass phrase provided by a user and need to turn that into a key, there
are various ways that could be done, depending on the size of key
you're after. (You could find the MD5 hash of it, for instance.)
Second, what is the IV array for and how do I know how to set that or is it
set automatically by the crypto class.

The IV is the Initialization Vector - it's basically the starting
state. You should make it the same when you start to decrypt as when
you start to decrypt. You could set it to all zeroes if you wanted - I
can't remember how big it needs to be, unfortunately, but you could
always find out by calling GenerateIV and then seeing how large the
resulting IV is.
 
Back
Top