MD5 Library in .NET

      我写的一个.net里面用于md5加密的类。

using System;
using System.Security.Cryptography;

namespace md5
{
    
/// <summary>
    
/// Class1 的摘要说明。
    
/// </summary>
    public class stringToMD5
    {
        
public stringToMD5()
        {
            
//
            
// TODO: 在此处添加构造函数逻辑
            
//
        }

        
public static string makeMD5(string source)
        {
            
byte[] b=System.Text.Encoding.Default.GetBytes(source);
            b
=new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(b);
            
string ret="";
            
for(int i=0;i<b.Length;i++)
                ret
+=b[i].ToString ("x").PadLeft(2,'0');
            
return ret;
        }
    }
}
原文地址:https://www.cnblogs.com/taobataoma/p/733244.html