SHA加密

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace SHA加密练习1
{
    class Program
    {
        static void Main(string[] args)
        {          
            Console.WriteLine("----------");
            string sha = Console.ReadLine();
            string sha_1= SHA_Encrypt(sha);
            Console.WriteLine(sha_1);
            Console.ReadKey();
        }
  

        public static string SHA_Encrypt(string sourceString)
        {
            byte[] StrRes = Encoding.UTF8.GetBytes(sourceString);
            HashAlgorithm iSHA = new SHA1CryptoServiceProvider();
            StrRes = iSHA.ComputeHash(StrRes);
            StringBuilder EnText = new StringBuilder();
            foreach (byte item in StrRes)
            {
                EnText.AppendFormat("{0:x2}", item);
            }
            return EnText.ToString();

        }

    }
}

上一篇:前端面试题必考(三)- HTTPS加密/常用JAVA加密算法基本知识


下一篇:SSL加速卡调研的原因及背景