Sha1 String hash - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:SHA1

Description

Sha1 String hash

Demo Code


using System.Text;
using System.Security.Cryptography;
using System.Collections.Generic;
using System;/* w  w w.  j a v a  2s.co  m*/

public class Main{
        public static string Sha1(string text)
        {
            byte[] buffer = Encoding.UTF8.GetBytes(text);
            SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider();
            byte[] outbuffer = cryptoTransformSHA1.ComputeHash(buffer);
            return Convert.ToBase64String(outbuffer);
        }
}

Related Tutorials