MD5加密
1
' ----------------------------------------------------
2
'The Encrypt method enables Encryt a clean string into hash
3
'
4
'加密字符串为hash
5
'
6
'SHA512Managed().ComputeHash(dataToHash)
7
'CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(data1ToHash)
8
'----------------------------------------------------
9
Public Shared Function Encrypt(ByVal cleanString As String) As String
10
'采用MD5
11
Dim clearBytes As [Byte]()
12
clearBytes = New UnicodeEncoding().GetBytes(cleanString)
13
Dim hashedBytes As [Byte]() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(clearBytes)
14
Dim hashedText As String = BitConverter.ToString(hashedBytes)
15![](/Images/OutliningIndicators/InBlock.gif)
16
'再采用MD5
17
clearBytes = New UnicodeEncoding().GetBytes(hashedText)
18
hashedBytes = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(clearBytes)
19
hashedText = BitConverter.ToString(hashedBytes)
20![](/Images/OutliningIndicators/InBlock.gif)
21
Return hashedText
22
End Function
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)