Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast and secure cryptography algorithm C#

Tags:

c#

encryption

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!

like image 909
StuffHappens Avatar asked Aug 13 '10 06:08

StuffHappens


People also ask

What is the fastest encryption algorithm?

Twofish is considered among the fastest encryption standards and is hence favoured for usage among hardware and software enterprises. It is freely available and hence makes it popular. The keys used in this algorithm may be up to 256 bits in length and only one key is needed.

Which is faster Blowfish or AES?

Blowfish and AES, on the other hand, are Symmetric Ciphers, that is, it uses only one key for both encryption and decryption. While Blowfish is the Fastest Encryption algorithm [2] , AES is the most secure and efficient in encrypting data [3].


2 Answers

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.

like image 145
NullUserException Avatar answered Sep 18 '22 18:09

NullUserException


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:

  • Steganography Article 1

  • Steganography Article 2

like image 42
VinayC Avatar answered Sep 16 '22 18:09

VinayC