[ASP.NET2.0]Common层通用代码之MD5

来源:互联网 发布:android pda扫描源码 编辑:程序博客网 时间:2024/04/30 10:36
using System;
using System.Collections.Generic;
using System.Text;
using System.Security;
using System.Security.Principal;
using System.Security.Cryptography;

namespace Common
{
    
public class MD5
    
{
        
public static string Encrypt(string password)
        
{
            
///获取Byte数组
            Byte[] clearBytes = new UnicodeEncoding().GetBytes(password);
            
///获取Hash值
            Byte[] hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);

            
///获取加密后的信息
            return BitConverter.ToString(hashedBytes);
        }

    }

}

 
原创粉丝点击