MD5码加密

private String Encrypt(String pwd)
    {
        try
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            Byte[] b = Encoding.Default.GetBytes(pwd);//将待加密字符转为 字节型数组
            Byte[] output = md5.ComputeHash(b);//将字节数组转为加密的字节数组
            pwd = BitConverter.ToString(output).Replace("-", "");//将数字转为string 型去掉内部的无关字符

            return pwd;
        }
        catch (Exception ex)
        {
            throw new ApplicationException(ex.Message);
        }
    }

posted on 2011-03-31 14:35  缘来  阅读(189)  评论(0)    收藏  举报

导航