积极答复者
vb.net winform 如何让登录密码 无法让任何人可以轻易的得知?

问题
答案
-
恩了解
刚刚在一个resource 找到的 在这里分享一个md5 的加密方法
Imports System.Security.Cryptography
Imports System.Text
Public Function MD5(ByVal st As String, ByVal bm As Short) As String
Dim num As Integer
Dim str As String
Dim bytes As Byte() = New ASCIIEncoding().GetBytes(st)
Dim buffer As Byte() = DirectCast(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(bytes)
Select Case bm
Case 16
num = 4
Do
str = (str & Conversion.Hex(buffer(num)).ToLower)
num += 1
Loop While (num <= 11)
Return str
Case 32
num = 0
Do
str = (str & Conversion.Hex(buffer(num)).ToLower)
num += 1
Loop While (num <= 15)
Return str
End Select
Dim num2 As Integer = (buffer.Length - 1)
num = 0
Do While (num <= num2)
str = (str & Conversion.Hex(buffer(num)).ToLower)
num += 1
Loop
Return str
End Function
要使用的话 只需使用此类似的 md5(textbox.text.trim,16)- 已标记为答案 xeraee 2009年3月26日 5:41
全部回复
-
恩了解
刚刚在一个resource 找到的 在这里分享一个md5 的加密方法
Imports System.Security.Cryptography
Imports System.Text
Public Function MD5(ByVal st As String, ByVal bm As Short) As String
Dim num As Integer
Dim str As String
Dim bytes As Byte() = New ASCIIEncoding().GetBytes(st)
Dim buffer As Byte() = DirectCast(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(bytes)
Select Case bm
Case 16
num = 4
Do
str = (str & Conversion.Hex(buffer(num)).ToLower)
num += 1
Loop While (num <= 11)
Return str
Case 32
num = 0
Do
str = (str & Conversion.Hex(buffer(num)).ToLower)
num += 1
Loop While (num <= 15)
Return str
End Select
Dim num2 As Integer = (buffer.Length - 1)
num = 0
Do While (num <= num2)
str = (str & Conversion.Hex(buffer(num)).ToLower)
num += 1
Loop
Return str
End Function
要使用的话 只需使用此类似的 md5(textbox.text.trim,16)- 已标记为答案 xeraee 2009年3月26日 5:41