zoukankan      html  css  js  c++  java
  • MD5和SHA加密测试

    有关MD5和SHA加密,程序在SharpDevelop环境下测试。注意XP只支持MD5和SHA1,其他的不受XP系统支持。


    using System;
    using System.Net.NetworkInformation;

    namespace DemoConsole
    {
        class Program
        {
            public static void Main(string[] args)
            {   
                byte[] bytes = System.Text.Encoding.UTF8.GetBytes("XU Minghui");
                System.Security.Cryptography.MD5CryptoServiceProvider //MD5加密,16字节,128位
                    md5 =new System.Security.Cryptography.MD5CryptoServiceProvider();
                Console.WriteLine(BitConverter.ToString( md5.ComputeHash(bytes)).Replace("-",string.Empty));
                //TODO:SHA加密:20字节160位;32字节256位;48字节384位;64字节512位
                System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
                System.Security.Cryptography.SHA256CryptoServiceProvider sha256 = new System.Security.Cryptography.SHA256CryptoServiceProvider();
                System.Security.Cryptography.SHA384CryptoServiceProvider sha384 = new System.Security.Cryptography.SHA384CryptoServiceProvider();
                System.Security.Cryptography.SHA512CryptoServiceProvider sha512 = new System.Security.Cryptography.SHA512CryptoServiceProvider();
                
                Console.WriteLine("{0}\n{1}\n{2}\n{3}\n",
                                  BitConverter.ToString(sha1.ComputeHash(bytes)).Replace("-",string.Empty),
                                  BitConverter.ToString(sha256.ComputeHash(bytes)).Replace("-",string.Empty),
                                  BitConverter.ToString(sha384.ComputeHash(bytes)).Replace("-",string.Empty),
                                  BitConverter.ToString(sha512.ComputeHash(bytes)).Replace("-",string.Empty));
                
                Console.Write("Press any key to continue . . . ");
                Console.ReadKey(true);
            }
        }
    }

  • 相关阅读:
    检索通讯录,根据输入的电话号码的每一位下拉显示检索结果
    获取手机的具体型号 及 iOS版本号
    在iOS中使用ZBar扫描二维码
    iOS沙盒路径的查看和使用
    ios打开通讯录及点击通讯录时提取相关信息
    获取倒计时距离某一时间点的时间,判断身份证,电话号码格式是否正确的简单封装
    iOS 获取手机的型号,系统版本,软件名称,软件版本
    第三天战略会议
    第二天站略会议总结
    第一天站略会议总结
  • 原文地址:https://www.cnblogs.com/flaaash/p/2022713.html
Copyright © 2011-2022 走看看