Clear texting symmetric Key and IV

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

Guest

I'm trying to figure out if the RijndaelManaged.generateKey and
RijndaelManaged.generateIV created an encrypted key and IV. If I attempt to
view this in clear text, it appears that the value is encrypted. How can I
decrypt these two values created by the generate methods? Below is sample
code...

class SymmetricKeyTest
{

public static void Main(string[] args)

{
try
{
RijndaelManaged rm = new RijndaelManaged();

rm.KeySize = 256;
rm.GenerateKey();
rm.GenerateIV();
byte[] theKey = rm.Key;
byte[] theIV = rm.IV;
ASCIIEncoding unicode = new ASCIIEncoding();
string key = unicode.GetString(theKey);
string iv = unicode.GetString(theIV);
Console.WriteLine("Key: {0}", key);
Console.WriteLine("IV: {0}", iv);

}catch(Exception e){
Console.WriteLine(e.Message);
}

Console.ReadLine();
}
}
 
phil said:
I'm trying to figure out if the RijndaelManaged.generateKey and
RijndaelManaged.generateIV created an encrypted key and IV. If I attempt to
view this in clear text, it appears that the value is encrypted.

They're not "encrypted" - they're just binary. You really, really
shouldn't use Encoding instances to try to convert arbitrary binary
data into text - they're only meant to be used to convert text data
into the binary representation using that encoding, and decode binary
data *which is correct for that encoding* back into text.

If you want to see the bytes involved in a hex format, you can use
BitConverter.ToString(byte[]).
 
Thanks for the response.

Jon Skeet said:
phil said:
I'm trying to figure out if the RijndaelManaged.generateKey and
RijndaelManaged.generateIV created an encrypted key and IV. If I attempt to
view this in clear text, it appears that the value is encrypted.

They're not "encrypted" - they're just binary. You really, really
shouldn't use Encoding instances to try to convert arbitrary binary
data into text - they're only meant to be used to convert text data
into the binary representation using that encoding, and decode binary
data *which is correct for that encoding* back into text.

If you want to see the bytes involved in a hex format, you can use
BitConverter.ToString(byte[]).
 

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

Back
Top