tags:

views:

82

answers:

3

Hello.

I'm looking for a fast and secure cryptography algorithm with C# implementation. I need to be able to restore the initial message. What could you suggest?

Thank you for your help!

+1  A: 

Do you need to use a public-key implementation? Or simply symmetric ciphers?

Do you need to encrypt a series of messages? Or just one message?

Do you need to interoperate with other programs or standards?

Is your application completely in charge of the key, or will the user supply a passphrase?

sarnold
The key will be stored inside the program and user won't supply anything. I don't need to interoperate with other programs or standards. I'll encrypt series of messages one by one.
StuffHappens
@StuffHappens: In that case AES-128 is fast and secure, and if somebody reverse engineers your application then you have no security at all. See @NullUserException's answer for info on the AESCryptoServiceProvider.
GregS
+4  A: 

If you need asymmetric encryption, use 2048-bits RSA.

If you can get away with symmetric encryption, use 256-bit AES.

MSDN Reference:

System.Security.Cryptography
RSACryptoServiceProvider
AesCryptoServiceProvider

You can read about the difference between them here: Symmetric versus Asymmetric.

NullUserException
+1  A: 

Based on your comments, symmetric encryption should do the trick for you - not to mention it would be faster than asymmetric one. You may want to look at RijndaelManaged class - its same as AES implementation but you have more flexibility in terms of block sizes.

Now, talking about security, it would depend upon how secure is your key. In your case, you are talking about storing it in code. So you need to secure your code/assemblies (say if it is going to lie on controlled server environment). A better option would be to put key in config file (provided config files are stored in controlled environment, they offers flexibility of changing it). In case, you wish to put in code and code/assembly but want to protect from reverse-engineering attacks - obfuscation coupled with Steganography would be way to go. Below are couple of articles on Steganography implementations in .NET:

VinayC