Implementation of MD5 encryption in vb in asp.net

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.