using System;
//声明.NET Framework提供加密服务的命名空间
using System.Security.Cryptography;
using System.Text;
//声明提供.NET Framework提供正确的正则表达式的命名空间
using System.Text.RegularExpressions;

namespace WKJSMD5
{
    
public class Security
    
{
        
public string Encrypt(string cleanString)
        
{
            
//将传入的参数转化为UIF-16编码格式的字节类型变量
            byte[] clearByte = new UnicodeEncoding().GetBytes(cleanString);
            
//将传入的阐述转化为经过MD5算法加密的字节类型变量
            byte[] hashedByte = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearByte);
            
//将经过加密计算的字节类型变量转化为string类型并返回
            return BitConverter.ToString(hashedByte);
        }

    }

}

 
posted on 2006-09-14 04:11  wkjs  阅读(160)  评论(0编辑  收藏  举报