天天看點

MD5加密處理

//引用命名空間

using System.Web.Security;  

//MD5加密後長度是32位   

FormsAuthentication.HashPasswordForStoringInConfigFile("abc","md5")   

//SH1加密後長度是40位   

FormsAuthentication.HashPasswordForStoringInConfigFile("abc", "sha1")  

//例子:

public string EncryptStr(string PWD, int Format)

    {

        string str = "";

        switch (Format)

        {

            case 0:

                str = FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "SHA1");

                break;

            case 1:

                str = FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "MD5");

        }

        return str;

    }

繼續閱讀