Skip to content

Instantly share code, notes, and snippets.

@foontzoot
Created September 23, 2016 02:10
Show Gist options
  • Save foontzoot/e83b1b9d4a458d42ccf9720905beffec to your computer and use it in GitHub Desktop.
Save foontzoot/e83b1b9d4a458d42ccf9720905beffec to your computer and use it in GitHub Desktop.
A working example of password encoding for ASP.NET
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