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


SHA256_K(16) = &HE49B69C1
SHA256_K(17) = &HEFBE4786
SHA256_K(18) = &HFC19DC6
SHA256_K(19) = &H240CA1CC
SHA256_K(20) = &H2DE92C6F
SHA256_K(21) = &H4A7484AA
SHA256_K(22) = &H5CB0A9DC
SHA256_K(23) = &H76F988DA
SHA256_K(24) = &H983E5152
SHA256_K(25) = &HA831C66D
SHA256_K(26) = &HB00327C8
SHA256_K(27) = &HBF597FC7
SHA256_K(28) = &HC6E00BF3
SHA256_K(29) = &HD5A79147
SHA256_K(30) = &H6CA6351
SHA256_K(31) = &H14292967
SHA256_K(32) = &H27B70A85
SHA256_K(33) = &H2E1B2138
SHA256_K(34) = &H4D2C6DFC
SHA256_K(35) = &H53380D13
SHA256_K(36) = &H650A7354
SHA256_K(37) = &H766A0ABB
SHA256_K(38) = &H81C2C92E
SHA256_K(39) = &H92722C85
SHA256_K(40) = &HA2BFE8A1
SHA256_K(41) = &HA81A664B
SHA256_K(42) = &HC24B8B70
SHA256_K(43) = &HC76C51A3
SHA256_K(44) = &HD192E819
SHA256_K(45) = &HD6990624
SHA256_K(46) = &HF40E3585
SHA256_K(47) = &H106AA070
SHA256_K(48) = &H19A4C116
SHA256_K(49) = &H1E376C08
SHA256_K(50) = &H2748774C
SHA256_K(51) = &H34B0BCB5
SHA256_K(52) = &H391C0CB3
SHA256_K(53) = &H4ED8AA4A
SHA256_K(54) = &H5B9CCA4F
SHA256_K(55) = &H682E6FF3
SHA256_K(56) = &H748F82EE
SHA256_K(57) = &H78A5636F
SHA256_K(58) = &H84C87814
SHA256_K(59) = &H8CC70208
SHA256_K(60) = &H90BEFFFA
SHA256_K(61) = &HA4506CEB
SHA256_K(62) = &HBEF9A3F7
SHA256_K(63) = &HC67178F2
End Sub
Private Sub Class_Terminate
End Sub
'字符传转换数组函数
Private Function ConvertToWordArray(byVal sMessage)
Dim lMessageLength
Dim lNumberOfWords
Dim lWordArray()
Dim lBytePosition
Dim lByteCount
Dim lWordCount
Const MODULUS_BITS = 512
Const CONGRUENT_BITS = 448
lMessageLength = Len(sMessage)
lNumberOfWords = (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD)
ReDim lWordArray(lNumberOfWords - 1)
lBytePosition = 0
lByteCount = 0
Do Until lByteCount >= lMessageLength
lWordCount = lByteCount \ BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
lByteCount = lByteCount + 1
Loop
lWordCount = lByteCount \ BYTES_TO_A_WORD
lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE
lWordArray(lWordCount) = lWordArray(lWordCount) or LShift(&H80, lBytePosition)
lWordArray(lNumberOfWords - 2) = LShift(lMessageLength, 3)
lWordArray(lNumberOfWords - 1) = RShift(lMessageLength, 29)
ConvertToWordArray = lWordArray
End Function

'字符串左移位主函数
Private Function LShift(byVal lValue, byVal iShiftBits)
If iShiftBits = 0 Then
LShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And 1 Then
LShift = &H80000000
Else
LShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 or iShiftBits > 31 Then

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

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