Ad Unit (Iklan) BIG

how to encrypt string value in sha1 using c#

using System;
using System.Security.Cryptography;
using System.Text;

namespace ajayvishu
{
    class Program
    {
        static void Main(string[] args)
        {
            string source = "Ajay Vishwakarma!";
            using (SHA1 sha1Hash = SHA1.Create())
            {
                //From String to byte array
                byte[] sourceBytes = Encoding.UTF8.GetBytes(source);
                byte[] hashBytes = sha1Hash.ComputeHash(sourceBytes);
                string hash = BitConverter.ToString(hashBytes).Replace("-",String.Empty);
                Console.WriteLine("The SHA1 hash of " + source + " is: " + hash);     
            }
        } 
    }
 }

Post a Comment

0 Comments