1、web項目中方法:
復制代碼 代碼如下:
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("aaaa","MD5")
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("aaaa","MD5")
查看文檔方法:
復制代碼 代碼如下:
PublicSharedFunctionHashPasswordForStoringInConfigFile(ByValpasswordAsString,ByValpasswordFormatAsString)AsString
成員屬于:System.Web.Security.FormsAuthentication
摘要:
給定標識哈希類型的密碼和字符串,該例程產生一個適合存儲在配置文件中的哈希密碼。
參數:
password:要進行哈希運算的密碼。
passwordFormat:要使用的哈希算法。選項有“sha1”或“md5”。
返回值:
返回一個包含哈希密碼的String。
PublicSharedFunctionHashPasswordForStoringInConfigFile(ByValpasswordAsString,ByValpasswordFormatAsString)AsString
成員屬于:System.Web.Security.FormsAuthentication
摘要:
給定標識哈希類型的密碼和字符串,該例程產生一個適合存儲在配置文件中的哈希密碼。
參數:
password:要進行哈希運算的密碼。
passwordFormat:要使用的哈希算法。選項有“sha1”或“md5”。
返回值:
返回一個包含哈希密碼的String。
2、vb的應用程序:
復制代碼 代碼如下:
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
您可能感興趣的文章:- ASP.NET中DES加密與解密MD5加密幫助類的實現代碼
- VB.NET實現的MD5加密算法示例【32位】
- .NET MD5加密解密代碼解析
- asp.net實現的MD5加密和DES加解密算法類完整示例
- asp.net實現md5加密
- asp.net中使用cookie與md5加密實現記住密碼功能的實現代碼
- ASP.NET中MD5與SHA1加密的幾種方法
- 徹底解決ASP.NET MD5加密中文結果和ASP不一致的問題
- asp.net下常用的加密算法MD5、SHA-1應用代碼
- asp.net中MD5 16位和32位加密函數
- ASP.net中md5加密碼的方法
- .net core使用MD5加密解密字符串