Created
September 23, 2016 02:10
-
-
Save foontzoot/e83b1b9d4a458d42ccf9720905beffec to your computer and use it in GitHub Desktop.
A working example of password encoding for ASP.NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string EncodePassword(string pass, string salt) | |
{ | |
byte[] bytes = Encoding.Unicode.GetBytes(pass); | |
byte[] src = Convert.FromBase64String(salt); | |
byte[] dst = new byte[src.Length + bytes.Length]; | |
Buffer.BlockCopy(src, 0, dst, 0, src.Length); | |
Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length); | |
HashAlgorithm algorithm = HashAlgorithm.Create("SHA1"); | |
byte[] inArray = algorithm.ComputeHash(dst); | |
return Convert.ToBase64String(inArray); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment