当前位置: 网学 > 编程文档 > ASP > 正文

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

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/16
8B70
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
Err.Raise 6
End If
If (lValue And MD5_m_l2Power(31 - iShiftBits)) Then
LShift = ((lValue And MD5_m_lOnBits(31 - (iShiftBits + 1))) * MD5_m_l2Power(iShiftBits)) or &H80000000
Else
LShift = ((lValue And MD5_m_lOnBits(31 - iShiftBits)) * MD5_m_l2Power(iShiftBits))
End If
End Function
''字符串右移位主函数
Private Function RShift(byVal lValue, byVal iShiftBits)
If iShiftBits = 0 Then
RShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And &H80000000 Then
RShift = 1
Else
RShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 or iShiftBits > 31 Then
Err.Raise 6
End If
RShift = (lValue And &H7FFFFFFE) \ MD5_m_l2Power(iShiftBits)
If (lValue And &H80000000) Then
RShift = (RShift or (&H40000000 \ MD5_m_l2Power(iShiftBits - 1)))
End If
End Function
''字符串偏移转换,通过左右移位函数实现
Private Function RotateLeft(byVal lValue, byVal iShiftBits)
RotateLeft = LShift(lValue, iShiftBits) or RShift(lValue, (32 - iShiftBits))
End Function
''追加无符号16进制编码

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号