Cryptography in .NET for Beginners

This is a brief introduction into .NET cryptography.

Hashes

Hashing is a transformation process of some input data of an arbitrary length into an array of bytes of fixed size.
Hash is a one-side transformation function, the result of which cannot be reversed for receiving original input data. Very often it is used to store passwords. Even if an attacker gets a hash, he can’t retrieve the password from it. The length of a hash is determined by a hashing algorithm. In .NET you can find the following hashing algorithms (all of which derive from the HashAlgorithm base class):

  • MD5 — 128 bits in length
  • SHA (Secure Hash Algorithm) — there is no such a class, but there are SHA1 (160 bits), SHA256, SHA384, SHA512
  • KeydHashAlgorithm (also known as Message Authentication Code). Represented by the following classes of  algorithms: HMAC and MACTripleDES

Continue reading