C# Secure Hash String





10
Date Submitted Tue. Sep. 19th, 2006 7:53 PM
Revision 1 of 1
Helper jbplou
Tags CSharp | Security | String
Comments 0 comments
Generates an 88 character secure hash string for the passed in strings.


                /// <summary>
                /// Generates an SHA type hash of the passed in value and salt.  Hash is 88 characters always
                /// </summary>
                /// <param name="valueToHash">The value for hasing</param>
                /// <param name="salt">SALT for the hash</param>
                /// <returns></returns>
                public static  string SHAHash(string valueToHash, string salt)
                {
                        System.Security.Cryptography.SHA512Managed hasher = new System.Security.Cryptography.SHA512Managed();
                        Byte[] valueToHashAsByte = System.Text.Encoding.UTF8.GetBytes(string.Concat(valueToHash, salt));
                        Byte[] returnBytes = hasher.ComputeHash(valueToHashAsByte);
                        hasher.Clear();
                        return Convert.ToBase64String(returnBytes);
                }
 

Jeff B

Comments

There are currently no comments for this snippet.

Voting