473,465 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Clear texting symmetric Key and IV

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();
}
}
Apr 27 '06 #1
2 4135
phil <ph**@discussions.microsoft.com> wrote:
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[]).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 27 '06 #2
Thanks for the response.

"Jon Skeet [C# MVP]" wrote:
phil <ph**@discussions.microsoft.com> wrote:
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[]).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Apr 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: kiran | last post by:
Hi , I need some helpon Symmetric Crptography algorithm. My friend has given a encrypted message ( encrypted using Symmetric cryptogrraphy algorithm and he does 't mention on which plat form is...
2
by: phil | last post by:
Where's the best place to store a symmetric key for a file encryption program? Is the registry a good idea?
0
by: Chris Fink | last post by:
I have walked through all of the WSE 3 Hands on Labs and got everything working fine. When I create my own certificate and install it in the stores, my client application that is consuming my WSE...
7
by: Mark Rae | last post by:
Hi, Picking your collective brains again, this time regarding the storage of the key used in symmetric encryption. Let's say you have a requirement to add encryption to a C# project, so you...
0
by: Summa | last post by:
I write encrypt symmetric key using X509 Certificate public key and write to a XML file. RijndaelManaged sCipher = new RijndaelManaged(); byte EnKey = sRSA.Encrypt(sCipher.Key,false); ...
1
by: lookaround | last post by:
Hi, I have a problem with UrlEncoding/UrlDecoding. I have two chars (東京); the HTTPUtility.UrlEncode writes in the html the text: %e6%9d%b1%e4%ba%ac The Request.Querystring.ToString() of...
8
by: =?Utf-8?B?RGFuTQ==?= | last post by:
Can someone help with the following problem. I am sending an encrypted SOAP message to a .NET 2.0 + WSE 3.0 web service. When .NET attempts to decrypt the message it cannot read the private key...
5
by: clintonG | last post by:
Where do I learn to send SMS-Texting messages? What kind of solutions do we have as C# developers using Microsoft? There is so much "mobile" this and that at MSDN I don't know where to start with...
4
lee123
by: lee123 | last post by:
does vb6 come with anything to make a texting app. lee123
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.