User Tools

Site Tools


notes:csharp:cryptography

Cryptography in C# and .NET

Algorithm Encryption Keys
Rijndael symmetric private/shared
Rivest
Shamir
Adleman
asymmetric public/private
Digital
Signature
Algorithm
asymmetric public/private
Hash Algorithm Description
Secure
Hash
Algorithm
stronger than MD5 against brute force attacks
Message
Digest
Algorithm 5
faster than SHA
RACE
Integrity
Primitives
Evaluation
Message
Digest
.

The purpose of hash algorithms is to create a fixed-length hash value from binary strings. The hash algorithms are used with digital signatures and for data integrity. If the same binary string is hashed again, the same hash value is returned.

Class Description
RijndaelManaged Implements shared key (symmetric) encryption. The encryption/decription algorithms using symmetric keys are much faster than those using asymmetric keys. The downside is that the keys must be exchanged in a safe manner.
RSACryptoServiceProvider Implements public key (asymmetric) encryption by using the RSA algorithm. With asymmetric encryption, a public key is used to encrypt data but a private key is used to decrypt data. The public key is known to everyone who must be able to encrypt data. The private key is known only to those who should decrypt data.
DSACryptoServiceProvider Implements asymmetric encryption by using the DSA algorithm.
SHA1Managed Computes a unique hash of data using the SHA algorithm. Hashing is a one-way process and hashed data cannot be reversed.

The .NET Framework contains classes for encryption in the namespace System.Security.Cryptography. The classes with a Cng (Cryptography Next Generation) prefix or suffix are newer versions of the native Crypto API. There are a few abstract classes such as MD5, SHA1, or DES. The classes with the suffix CryptoServiceProvider implement the abstract base classes.

Category Classes Description
Hash MD5 (abstract), MD5Cng
SHA1 (abstract), SHA1Managed, SHA1Cng
SHA256 (abstract), SHA256Managed, SHA256Cng
SHA384 (abstract), SHA384Managed, SHA384Cng
SHA512 (abstract), SHA512Managed, SHA512Cng
RIPEMD160 (abstract), RIPEMD160Managed
.
notes/csharp/cryptography.txt · Last modified: 2017/12/12 by leszek