现在的位置: 首页 > 综合 > 正文

用户加密函数

2012年11月19日 ⁄ 综合 ⁄ 共 464字 ⁄ 字号 评论关闭

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
using System.Security.Cryptography;
using System.Text;

class Encrypt()
{
/// <summary>
  /// 用户加密函数
  /// </summary>
  public static String Encrypt(string password)
  {
   Byte[] clearBytes = new UnicodeEncoding().GetBytes(password);
   Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);

   return BitConverter.ToString(hashedBytes);
  }  
}

抱歉!评论已关闭.