I'm confuddled - Byte Arrays

R

Rob

Hi all,

Ok - I've been toiling with some encyption - and I think I found why I
was having a problem, it was because my encrypt and decrypt functions
were using different keys....anyway...putting that to one side for the
moment...

Here's what I'm stuck with...

Dim rijndaelManaged As rijndaelManaged
Dim myKey As Byte()
Dim myKeyString As String

rijndaelManaged = New rijndaelManaged

myKey = rijndaelManaged.Key

myKeyString = Convert.ToBase64String(myKey)

myKey = Nothing
myKey = UnicodeEncoding.GetBytes(myKeyString)

In the above, what I am trying to do is take a key from the the
provider, convert it to a string, then back to a byte array, and then
set it as the key again.

Ok - you are probably wondering why - good question - in the example I
was following they had output the key that was generated when
instantiating a new provider, I thought I'd use that as the key for
both of my functions, but when I then converted that string back to a
byte array and set it as the key, it moans (like a cheap lady of the
streets) that the key had an invalid length (also not disimilar from a
cheap lady of the streets!).

Can someone tell me where I am going wrong please - I suspect this is
just me making stupid mistakes and not fulling understanding the syntax
for the byte arrays...

Thanks in advance for your help.

Regards

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top