public static string Hash(string password, HashScheme scheme) { switch (scheme) { case HashScheme.Plaintext: return password; default: case HashScheme.SHA1: return SHAHasher_5xN.Hash(password); } }
public static string Hash(string password, HashScheme scheme) { switch (scheme) { case HashScheme.Plaintext: return(password); default: case HashScheme.SHA1: return(SHAHasher_5xN.Hash(password)); } }
private string ShortenDirect(string url) { string key; if (Repository.ContainsValue(url)) { key = Repository.GetKey(url); } else { key = HashScheme.GetKey(url); int permutation = 0; while (Repository.ContainsKey(key)) { if (permutation == MaximumHashAttempts) { throw new Exception(String.Format("Failed to find a unique hash for url <{0}> after {1} attempts", url, permutation)); } key = HashScheme.GetKey(url, ++permutation); } Repository.Add(key, url); } return(CompleteUrl(key)); }
public static bool Verify(string password, string hash, HashScheme scheme) { return hash == Hash(password, scheme); }
public static bool Verify(string password, string hash, HashScheme scheme) { return(hash == Hash(password, scheme)); }