1. Methods in Web Projects:
Copy Code code as follows:
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile ("AAAA", "MD5")
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile ("AAAA", "MD5")
To view document methods:
Copy Code code as follows:
Publicsharedfunctionhashpasswordforstoringinconfigfile (byvalpasswordasstring,byvalpasswordformatasstring) Asstring
Members belong to: System.Web.Security.FormsAuthentication
Summary:
Given a password and string that identifies the hash type, this routine produces a hash password that is appropriate for storing in the configuration file.
Parameters:
Password: the password to be hashed.
Passwordformat: The hash algorithm to use. Options have "SHA1" or "MD5".
return value:
Returns a string that contains a hash password.
Publicsharedfunctionhashpasswordforstoringinconfigfile (byvalpasswordasstring,byvalpasswordformatasstring) Asstring
Members belong to: System.Web.Security.FormsAuthentication
Summary:
Given a password and string that identifies the hash type, this routine produces a hash password that is appropriate for storing in the configuration file.
Parameters:
Password: the password to be hashed.
Passwordformat: The hash algorithm to use. Options have "SHA1" or "MD5".
return value:
Returns a string that contains a hash password.
2, VB application:
Copy Code code 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