C# - symetric text encryption for a beginner

I'm trying to do some basic symetric text encryption with C# and the .NET framework.  I have a string variable with data and I need to have it encrypted and stored into another string variable.

I know there are a lot of examples out there, but I'm new and am having a little trouble wrapping my brain around a lot of what I'm finding.  Can somone please give me some basic example code that I can use to accomplish the above mentioned task?
Who is Participating?
josephdaviskcrmAuthor Commented:
Ok... so once again... I'm needing help interpreting and making these work.  I've been looking at the second link that you posted and have been trying to make this encryption class that he is using work for me.  I've got the entire class saved as a class file and I'm referencing it in the code below.  The code runs without any syntax errors, but the result of the encryption function is just a bunch of squares...

Àg%‹|h8c¤nÚÃó€U £)åÈ`½¥ûšð

Is it supposed to show up like that?  What I'm looking for is something that will give me an encrypted ASCII string so I can shove it in the a varchar field in a database.
byte[] key; byte[] iv;
key = UnicodeEncoding.Unicode.GetBytes("cornhle");
iv = UnicodeEncoding.Unicode.GetBytes("abcdefg");
strUniqueID = Encryption.EncryptData(strUniqueID, out key, out iv);

Open in new window

askbConnect With a Mentor Commented:
Then you would need to encode the encrypted binary string in some know format (base64)  which would be suitable to store it as a string,

Later, you need to decode the encoded sting first and then decrypt.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.