1. web project methods:
Copy codeThe Code is as follows: System. Web. Security. FormsAuthentication. HashPasswordForStoringInConfigFile ("aaaa", "MD5 ")
System. Web. Security. FormsAuthentication. HashPasswordForStoringInConfigFile ("aaaa", "MD5 ")
How to view the document:Copy codeThe Code is as follows: PublicSharedFunctionHashPasswordForStoringInConfigFile (ByValpasswordAsString, ByValpasswordFormatAsString) AsString
Member: System. Web. Security. FormsAuthentication
Abstract:
Given the password and string that identify the hash type, this routine generates a hash password suitable for storing in the configuration file.
Parameters:
Password: the password for hashing.
PasswordFormat: the hash algorithm to use. Options include "sha1" or "md5 ".
Return Value:
Returns a String containing the hash password.
PublicSharedFunctionHashPasswordForStoringInConfigFile (ByValpasswordAsString, ByValpasswordFormatAsString) AsString
Member: System. Web. Security. FormsAuthentication
Abstract:
Given the password and string that identify the hash type, this routine generates a hash password suitable for storing in the configuration file.
Parameters:
Password: the password for hashing.
PasswordFormat: the hash algorithm to use. Options include "sha1" or "md5 ".
Return Value:
Returns a String containing the hash password.
2. vb Applications:Copy codeThe Code is as follows: PublicSharedFunctionmd5str (ByRefstrSourceAsString)
DimdataToHashAsByte () = (NewSystem. Text. UnicodeEncoding). GetBytes (strSource. ToCharArray)
DimhashvalueAsByte () = CType (Cryptography. CryptoConfig. CreateFromName ("MD5"), Cryptography. HashAlgorithm). ComputeHash (dataToHash)
DimstrSBAsNewSystem. Text. StringBuilder
ForiAsInt16 = 0Tohashvalue. Length-1
StrSB. Append (hashvalue (I). ToString ("x2 "))
Next
DimcreatMD5 = strSB. ToString
ReturncreatMD5
EndFunction
PublicSharedFunctionmd5str (ByRefstrSourceAsString)
DimdataToHashAsByte () = (NewSystem. Text. UnicodeEncoding). GetBytes (strSource. ToCharArray)
DimhashvalueAsByte () = CType (Cryptography. CryptoConfig. CreateFromName ("MD5"), Cryptography. HashAlgorithm). ComputeHash (dataToHash)
DimstrSBAsNewSystem. Text. StringBuilder
ForiAsInt16 = 0Tohashvalue. Length-1
StrSB. Append (hashvalue (I). ToString ("x2 "))
Next
DimcreatMD5 = strSB. ToString
ReturncreatMD5
EndFunction