本文介绍了密码和SQL的哈希系统中的特殊问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我使用哈希系统来存储密码。
这个问题很特殊,因为只有第一个才会发生userid的字母表(用于身份验证)很小'n'。
在sql中保存时,2个数字会被更改。 (编号(2)和(3))
以下是我在调试时恢复的相关哈希序列:
使用的案例是用户:neetu和密码:123456
Hi All,
I am using hash system for storing password.
The problem is peculiar because it only happens if the first alphabet of the userid (used for authentication) is small 'n'.
2 numbers gets changed while saving in sql. (no. (2) and (3))
Below are the related hash sequences i recovered while debugging:
the case used is user: neetu and password: 123456
Public Function fnHashedValue(ByVal value, ByVal authentication)
'To Convert string into hash for storing and comparision
Dim sSourceData As String = value + authentication
'Create a byte array from source data.
Dim tmpSource() As Byte = ASCIIEncoding.ASCII.GetBytes(sSourceData)
'Compute hash based on source data.
Dim tmpHash() As Byte = New SHA1CryptoServiceProvider().ComputeHash(tmpSource)
Return tmpHash
End Function
tmpNewHash ? tmpSavedHash
{Length=20} {Length=20}
(0): 54 (0): 54
(1): 236 (1): 236
(2): 128 (2): 253
(3): 223 (3): 255
(4): 250 (4): 250
(5): 49 (5): 49
(6): 33 (6): 33
(7): 163 (7): 163
(8): 231 (8): 231
(9): 207 (9): 207
(10): 11 (10): 11
(11): 187 (11): 187
(12): 221 (12): 221
(13): 23 (13): 23
(14): 28 (14): 28
(15): 193 (15): 193
(16): 87 (16): 87
(17): 10 (17): 10
(18): 103 (18): 103
(19): 1 (19): 1
推荐答案
Private Function ByteArrayToString(ByVal arrInput() As Byte) As String
Dim i As Integer
Dim sOutput As New StringBuilder(arrInput.Length)
For i = 0 To arrInput.Length - 1
sOutput.Append(arrInput(i).ToString("X2"))
Next
Return sOutput.ToString()
End Function
这篇关于密码和SQL的哈希系统中的特殊问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!