5

I need to encrypt bytecode to send over a connection to a webservice, preferably using a GUID as a key. I have done a bit of research and found several classes developed for a similar purpose, but haven't been able to turn up much that is built into the Windows libraries. My question is: Is there something built in to C# that performs this task? If there is not, I would very much appreciate any suggestions as to implementation.

Edit: After reading this post When would I choose AesCryptoServiceProvider over AesManaged or RijndaelManaged? I am going with AESCryptoServiceProvider.

Community
  • 1
  • 1
badpanda
  • 2,446
  • 5
  • 34
  • 45
  • 3
    You didn't find System.Secuirty.Cryptography classes? As for using a GUID as a 'key' it really sounds like you should grab a copy of Applied Cryptography and read it cover-cover. – Heath Hunnicutt Jun 11 '10 at 21:07
  • 1
    encryption and decryption with Rijndael (ok, the example is about a file, but you can use it for any bytecode): http://stackoverflow.com/questions/740837/how-to-create-a-password-protected-file-in-c/740859#740859 – tanascius Jun 11 '10 at 21:08
  • >< I will do that, I am just an intern at a company and I don't have my degree yet...I am working off a fairly limited knowledge base so I really appreciate the suggestions! – badpanda Jun 11 '10 at 21:12
  • 2
    an important distinction to understand is that C# has not built-in classes for encryption or anything else. All of that is in the .NET Framework. – John Saunders Jun 12 '10 at 20:33

1 Answers1

11

You should check out the System.Security.Cryptography namespace.

It's not clear whether you're in a position to choose which algorithm etc to use, but you might consider one of the following symmetric algorithms:

There are also implementations of DES and RC2, but I would probably ignore them unless you're forced to use them.

LukeH
  • 263,068
  • 57
  • 365
  • 409
  • 1
    @badpanda: I'm no expert, but I would personally choose AES simply because it's seen as the standard modern algorithm. (AES is essentially the same as Rijndael, but Rijndael allows some configurations which weren't included in the AES standard. TripleDES is still widely used, but newer algorithms such as AES are widely viewed as being faster and more secure.) – LukeH Jun 11 '10 at 21:41