private void SetPassword(string password, byte[] salt = null, HashUtility.SupportedMethods method = HashUtility.SupportedMethods.SHA512) { if (salt == null || salt.Length == 0) { salt = HashUtility.GenerateSalt(); } byte[] ph = HashUtility.CreateHash(method, password, salt); this.Method = method; this.Salt = salt; this.Hash = ph; }
public static HashedPassword FromPassword(string rawPassword, byte[] salt = null, HashUtility.SupportedMethods method = HashUtility.SupportedMethods.SHA512) { var ret = new HashedPassword(); ret.SetPassword(rawPassword, salt, method); return(ret); }