• 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);
  • 相关阅读:
    poj 1562 Oil Deposits
    poj 1650 Integer Approximation
    snmp4j 编程
    ubuntu 13.04 163源(亲测可用)
    c语言中static 用法总结(转)
    Spring入门
    Hibernate入门
    Struts2入门教程
    素数距离问题
    ASCII码排序
  • 原文地址:https://www.cnblogs.com/adodo1/p/4327918.html
Copyright © 2020-2023  润新知