How To: Hash Data with Salt (C#/VB.NET)
The code below demonstrates how to hash data and verify hashes. It supports MD5, SHA-1, SHA-256, SHA-384, and SHA-512 hashing algorithms. To help reduce the risk of dictionary attacks, the code appends random bytes (so-called "salt") to the original plain text before generating hashes. Please keep in mind that salt can only help against prebuilt dictionaries. If an intruder gets access to your system and uses a brute force attack, salt will not provide much value. Code samples are provided in C# and Visual Basic.NET. IMPORTANT: DATA HASHES CANNOT BE "DECRYPTED" BACK TO PLAIN TEXT.