常用加密算法

类别:.NET开发 点击:0 评论:0 推荐:
public static string HashCryptString(string strText,string method){
            if(method == "MD5"){
                strText = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strText,"MD5");
//                MD5 md5 = new MD5CryptoServiceProvider();
//              strText = System.Text.Encoding.UTF8.GetString(md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(strText)));
            }
            else if(method == "SHA1"){
                strText = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strText,"SHA1");
//                SHA1 sha1 = new SHA1CryptoServiceProvider();
//                strText = System.Text.Encoding.UTF8.GetString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(strText)));
            }
            return strText;
        }

本文地址:http://com.8s8s.com/it/it43347.htm