1.MD5編碼在asp.net中的密碼和用戶名中的應用
private string strInfo_StoreName = "";
private string strInfo_StorePassword = "";
private string strPathName = "c://Inetpub//wwwroot//port//Administrator.txt";
private string strPathPassword = "c://Inetpub//wwwroot//port//Password.txt";
public void SetInfoName( string strInfo_Name )
{
strInfo_StoreName = EncryptPassword( strInfo_Name, "MD5" );
using ( StreamWriter sw1 = new System.IO.StreamWriter( strPathName ) )
{
sw1.WriteLine ( strInfo_StoreName );
}
}
public string RequireInfoName()
{
using( StreamReader sr1 = new StreamReader( strPathName ) )
{
strInfo_StoreName = sr1.ReadLine();
}
return strInfo_StoreName.ToString();
}
public void SetInfoPassword( string strInfo_Password )
{
strInfo_StorePassword = EncryptPassword( strInfo_Password, "MD5" );
using ( StreamWriter sw2 = new System.IO.StreamWriter( strPathPassword ) )
{
sw2.WriteLine ( strInfo_StorePassword );
}
}
public string RequirePassword()
{
using( StreamReader sr2 = new StreamReader( strPathPassword ) )
{
strInfo_StorePassword = sr2.ReadLine();
}
return strInfo_StorePassword.ToString();
}
public string EncryptPassword( string PasswordString, string PasswordFormat )
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString ,"MD5").ToString();
}