Created
November 6, 2015 06:10
-
-
Save gayancc/dc4f0d9292071ac272db to your computer and use it in GitHub Desktop.
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 virtual string CreatePasswordHash(string password, string saltkey, string passwordFormat = "SHA1") | |
{ | |
if (String.IsNullOrEmpty(passwordFormat)) | |
passwordFormat = "SHA1"; | |
string saltAndPassword = String.Concat(password, saltkey); | |
var algorithm = HashAlgorithm.Create(passwordFormat); | |
if (algorithm == null) | |
throw new ArgumentException("Unrecognized hash name", "hashName"); | |
var hashByteArray = algorithm.ComputeHash(Encoding.UTF8.GetBytes(saltAndPassword)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment