Supports 512 bit hash algorithm - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:Hash

Description

Supports 512 bit hash algorithm

Demo Code


using System.Security.Cryptography;
using System.IO;/* w  w  w  .  ja v  a 2s. c  o m*/
using System;

public class Main{
        /// <summary>
      /// Supports 512 bit hash algorithm
      /// </summary>
      /// <param name="input"></param>
      /// <returns></returns>
      public static byte[] HashToBuffer512(byte[] input)
      {
         HashAlgorithm sha = new SHA512CryptoServiceProvider();
         return sha.ComputeHash(input);
      }
        /// <summary>
      /// Supports 512 bit hash algorithm
      /// </summary>
      /// <param name="input"></param>
      /// <returns></returns>
      public static byte[] HashToBuffer512(string input)
      {
         MemoryStream stream = new MemoryStream();
         StreamWriter writer = new StreamWriter(stream);
         writer.Write(input);
         writer.Flush();
         stream.Position = 0;
         HashAlgorithm sha = new SHA512CryptoServiceProvider();
         return sha.ComputeHash(stream);
      }
}

Related Tutorials