Cryptography vs encryption: Cryptography is the science of concealing messages with a secret code. Encryption is the way to encrypt and decrypt data.
.Net provides classes in the namespace System.Security.Cryptography
Rfc2898DeriveBytes
Suggested use case would be for a one way hash
although it CAN BE de-hashed with a key and salt.
HMACSHA512
C# code examples here.
Suggested use case would be for signing a payload
so it can be de-hashed with a key, the salt is optional.
Ciphertext is encrypted text transformed from plaintext using an encryption algorithm. Ciphertext can’t be read until it has been converted into plaintext (decrypted) with a key. The decryption cipher is an algorithm that transforms the ciphertext back into plaintext.
SHA2
The most commonly used is SHA-256 as there are many SHA2 variants. produces a 256-bit has (64 hexadecimal digits).
SHA1
Has known to be insecure with a bunch of practical collision attacks already publicly disclosed.
SHA1, Secure Hash Algorithm v1 produces a 160-bit hash (20 bytes). In hexadecimal format it is an integer 40 digits long.
Example from geekytidbits.com
1 | var password = "qwerty"; |
MD5
Has known to be insecure with a bunch of practical collision attacks already publicly disclosed.
MD5 produces a 128-bit hash value, there is an example here to hash a password using MD5 with salt.
1 | carl // string |