ASP 改良版MD5、SHA256多重加密类(二次及多次)(6)


MD5_HH b, c, d, a, x(k + 6), S34, &H4881D05
MD5_HH a, b, c, d, x(k + 9), S31, &HD9D4D039
MD5_HH d, a, b, c, x(k + 12), S32, &HE6DB99E5
MD5_HH c, d, a, b, x(k + 15), S33, &H1FA27CF8
MD5_HH b, c, d, a, x(k + 2), S34, &HC4AC5665
MD5_II a, b, c, d, x(k + 0), S41, &HF4292244
MD5_II d, a, b, c, x(k + 7), S42, &H432AFF97
MD5_II c, d, a, b, x(k + 14), S43, &HAB9423A7
MD5_II b, c, d, a, x(k + 5), S44, &HFC93A039
MD5_II a, b, c, d, x(k + 12), S41, &H655B59C3
MD5_II d, a, b, c, x(k + 3), S42, &H8F0CCC92
MD5_II c, d, a, b, x(k + 10), S43, &HFFEFF47D
MD5_II b, c, d, a, x(k + 1), S44, &H85845DD1
MD5_II a, b, c, d, x(k + 8), S41, &H6FA87E4F
MD5_II d, a, b, c, x(k + 15), S42, &HFE2CE6E0
MD5_II c, d, a, b, x(k + 6), S43, &HA3014314
MD5_II b, c, d, a, x(k + 13), S44, &H4E0811A1
MD5_II a, b, c, d, x(k + 4), S41, &HF7537E82
MD5_II d, a, b, c, x(k + 11), S42, &HBD3AF235
MD5_II c, d, a, b, x(k + 2), S43, &H2AD7D2BB
MD5_II b, c, d, a, x(k + 9), S44, &HEB86D391
'加密步骤3:追加无符号转换
a = AddUnsigned(a, AA)
b = AddUnsigned(b, BB)
c = AddUnsigned(c, CC)
d = AddUnsigned(d, DD)
Next
If sType = 32 Then
'加密步骤4:分割合并各8位16进制转换
MD5 = LCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d))
Else
MD5 = LCase(WordToHex(b) & WordToHex(c))
End If
End Function
Private Function SHA256_LShift(byVal lValue, byVal iShiftBits)
If iShiftBits = 0 Then
SHA256_LShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And 1 Then
SHA256_LShift = &H80000000
Else
SHA256_LShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 or iShiftBits > 31 Then
Err.Raise 6
End If
If (lValue And SHA256_m_l2Power(31 - iShiftBits)) Then
SHA256_LShift = ((lValue And SHA256_m_lOnBits(31 - (iShiftBits + 1))) * SHA256_m_l2Power(iShiftBits)) or &H80000000
Else
SHA256_LShift = ((lValue And SHA256_m_lOnBits(31 - iShiftBits)) * SHA256_m_l2Power(iShiftBits))
End If
End Function
Private Function SHA256_RShift(byVal lValue, byVal iShiftBits)
If iShiftBits = 0 Then
SHA256_RShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And &H80000000 Then
SHA256_RShift = 1
Else
SHA256_RShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 or iShiftBits > 31 Then
Err.Raise 6
End If
SHA256_RShift = (lValue And &H7FFFFFFE) \ SHA256_m_l2Power(iShiftBits)
If (lValue And &H80000000) Then
SHA256_RShift = (SHA256_RShift or (&H40000000 \ SHA256_m_l2Power(iShiftBits - 1)))
End If
End Function
Private Function SHA256_AddUnsigned(byVal lX, byVal lY)
Dim lX4
Dim lY4
Dim lX8
Dim lY8
Dim lResult
lX8 = lX And &H80000000
lY8 = lY And &H80000000
lX4 = lX And &H40000000
lY4 = lY And &H40000000
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 Then
lResult = lResult Xor &H80000000 Xor lX8 Xor lY8

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2198.html