• C# MD5 SHA1 SHA256 SHA384 SHA512 示例 标准版 专业版 旗舰版


    转http://www.cnblogs.com/hongcing/archive/2010/02/03/1662608.html   //如果是文本,先转换为字节序列,如果有汉字,请不要使用 ASCII 编码,会导致汉字变成问号 byte[] buffer = Encoding.UTF8.GetBytes("洪星的博客");//UTF-8 编码 buffer = Encoding.Default.GetBytes("洪星的博客");//GBK/GB2312 编码 //16字节,128位 MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider(); byte[] h1 = MD5.ComputeHash(buffer); //20字节,160位 SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); byte[] h2 = SHA1.ComputeHash(buffer); //32字节,256位 SHA256CryptoServiceProvider SHA256 = new SHA256CryptoServiceProvider(); byte[] h3 = SHA256.ComputeHash(buffer); //48字节,384位 SHA384CryptoServiceProvider SHA384 = new SHA384CryptoServiceProvider(); byte[] h4 = SHA384.ComputeHash(buffer); //64字节,512位 SHA512CryptoServiceProvider SHA512 = new SHA512CryptoServiceProvider(); byte[] h5 = SHA512.ComputeHash(buffer); string s1 = BitConverter.ToString(h1).Replace("-", string.Empty); string s2 = BitConverter.ToString(h2).Replace("-", string.Empty); string s3 = BitConverter.ToString(h3).Replace("-", string.Empty); string s4 = BitConverter.ToString(h4).Replace("-", string.Empty); string s5 = BitConverter.ToString(h5).Replace("-", string.Empty); Console.WriteLine(s1); Console.WriteLine(s2); Console.WriteLine(s3); Console.WriteLine(s4); Console.WriteLine(s5);
  • 相关阅读:
    区间DP入门
    Prime Permutation(思维好题 )
    小字辈 (bfs好题)
    博弈论小结之尼姆博弈
    Hometask
    Lucky Sum (dfs打表)
    对称博弈
    尼姆博弈
    莫队算法 ( MO's algorithm )
    Codeforces 988D Points and Powers of Two ( 思维 || 二的幂特点 )
  • 原文地址:https://www.cnblogs.com/adodo1/p/4327195.html
Copyright © 2020-2023  润新知