Beispiel #1
0
 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));
 }
Beispiel #2
0
        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)));
        }