public static byte[] Hash(this string value, HashAlgorithim algorithm) { HashAlgorithm hash; switch (algorithm) { case HashAlgorithim.Md5: hash = new MD5CryptoServiceProvider(); break; case HashAlgorithim.Sha1: hash = new SHA1CryptoServiceProvider(); break; default : throw new ArgumentException("algorithm"); } return hash.ComputeHash(Encoding.UTF8.GetBytes(value)); }
public static byte[] Hash(this string value, HashAlgorithim algorithm) { HashAlgorithm hash; switch (algorithm) { case HashAlgorithim.Md5: hash = new MD5CryptoServiceProvider(); break; case HashAlgorithim.Sha1: hash = new SHA1CryptoServiceProvider(); break; default: throw new ArgumentException("algorithm"); } return(hash.ComputeHash(Encoding.UTF8.GetBytes(value))); }