[收集]MD5的加密在.net中的應用

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();
  }

 
發佈了17 篇原創文章 · 獲贊 1 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章