May 29, 2001

Cryptography in .NET

Secret-key encryption (symmetric cryptography)

Performs a transformation on data, keeping the data from being read by third parties. This type of encryption uses a single shared, secret key to encrypt and decrypt data.

.NET provides following Symmetric cAlgorithms (System.Security.Cryptography.SymmetricAlgorithm)


  • System.Security.Cryptography.DES
  • System.Security.Cryptography.RC2
  • System.Security.Cryptography.Rijndael
  • System.Security.Cryptography.TripleDES

Public-key encryption (asymmetric cryptography)

Performs a transformation on data, keeping the data from being read by third parties. This type of encryption uses a public/private key pair to encrypt and decrypt data.

In .NET System.Security.Cryptography provides RSA and DSA asymmetric algorithms

Digital Signatures

Helps verify that data originates from a specific party by creating a digital signature that is unique to that party. This process also uses hash functions.

The .NET Framework provides the following classes that implement digital signature algorithms:

  • DSACryptoServiceProvider
  • RSACryptoServiceProvider
Cryptographic hashes

Maps data from any length to a fixed-length byte sequence. Hashes are statistically unique; a different two-byte sequence will not hash to the same value.

Message authentication code (MAC) hash functions are commonly used with digital signatures to sign data, while message detection code (MDC) hash functions are used for data integrity.

The .NET Framework provides the following classes for hashing algorithms:
  • HMACSHA1
  • MACTripleDES
  • MD5CryptoServiceProvider
  • SHA1
  • Managed
  • SHA256Managed
  • SHA384Managed
  • SHA512 Managed