/// <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.IsNull())
         return null;
     using (HashAlgorithm Hasher = Algorithm.NullCheck(()=>new SHA1CryptoServiceProvider()))
     {
         byte[] HashedArray = Hasher.ComputeHash(Data);
         Hasher.Clear();
         return HashedArray;
     }
 }
Example #2
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.IsNull())
         return null;
     using (HashAlgorithm hasher = algorithm.NullCheck(() => new SHA1CryptoServiceProvider()))
     {
         byte[] hashedArray = hasher.ComputeHash(data);
         hasher.Clear();
         return hashedArray;
     }
 }