コード例 #1
0
 /// <summary>
 /// Computes the hash of a byte array
 /// </summary>
 /// <param name="Data">Byte array to hash</param>
 /// <param name="Algorithm">Hash algorithm to use (defaults to SHA1)</param>
 /// <returns>The hash of the byte array</returns>
 public static byte[] Hash(this byte[] Data, HashAlgorithm Algorithm = null)
 {
     if (Data==null)
         return null;
     using (HashAlgorithm Hasher = Algorithm.Check(()=>new SHA1CryptoServiceProvider()))
     {
         byte[] HashedArray = Hasher.ComputeHash(Data);
         Hasher.Clear();
         return HashedArray;
     }
 }