用C#中的FormsAuthentication.HashPasswordForStoringInConfigFile 方法可以把字符串进行加密,但能不能反过来解密呢? ?

解决方案 »

  1.   

    md5加密方法
    public string Encrypt(string password)
        {   
            Byte[] clearBytes = new UnicodeEncoding().GetBytes(password);
            Byte[] hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
            return BitConverter.ToString(hashedBytes);
        }
     System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("要加密的字符串", System.Web.Configuration.FormsAuthPasswordFormat.MD5.ToString());
    参考