Hash To Byte array Buffer - CSharp System

CSharp examples for System:Byte Array

Description

Hash To Byte array Buffer

Demo Code


using System.Security.Cryptography;
using System.IO;/*from ww  w.  java 2  s  .  co m*/
using System;

public class Main{
    public static byte[] HashToBuffer(byte[] input)
      {
         HashAlgorithm sha = new SHA1CryptoServiceProvider();
         return sha.ComputeHash(input);
      }
    public static byte[] HashToBuffer(string input)
      {
         MemoryStream stream = new MemoryStream();
         StreamWriter writer = new StreamWriter(stream);
         writer.Write(input);
         writer.Flush();
         stream.Position = 0;
         HashAlgorithm sha = new SHA1CryptoServiceProvider();
         return sha.ComputeHash(stream);
      }
}

Related Tutorials