I like Jon's solution better, but another option is to just save the hexadecimal hexadecimal text as a string. Replace the last line as follows:
return BitConverter.ToString(computedHash)
One thing you can consider is password strength.
SHA1 is very fast, sometimes too fast. The system will be able to calculate a couple of million hashes per second. Speed ββallows an attacker to try a standard dictionary dictionary attack (including capitalization options) and numerical extensions. SHA1 speed allows you to expand the space of dictionaries in a reasonable time, breaking most user passwords.
The method of password amplification is a hash code several times, which increases the requirements for the hash processor. Take the output of the SHA1 hash and pass it as input for the second round. Do this at least 1000 times. This slows down the calculation of the hash for both you and the attacker. For your users, this delays access after a trivial amount of time; the procedure will return in 0.01 seconds instead of 0.0001 seconds. However, to a brute force attack, you increased the execution time by 1000 times.
You can collapse your own, but the .net framework provides a class to do just that: System.Security.Cryptography.Rfc2898DeriveBytes
RFC2898 uses the SHA1 algorithm and accepts plain text, salt, and number of iterations. It can output a variable-length key.
http://msdn.microsoft.com/en-us/library/system.security.cryptography.rfc2898derivebytes.aspx
Gerald davis
source share