求MD5加密程序的代码
解决方案 »
- ACCESS数据库中合并行(元组)
- AutoCAD2000不支持VBA保存当前文档?
- 向qq聊天窗口的文本框写入字符的方法
- 如何在自己开发的控件中如何加载滚动条??
- VB做的DLL文件与其它语言做的DLL有什么具体的不同之处?为什么不同?
- 数据库查询代码如下,但我查找时总说没有符合条件的记录,请大家帮个小忙,走过路过,不要错过
- 简单问题,解决加分
- 急呀,请问我用CreateWindowEx创建的SysIPAddress32控件,怎么添加KeyPress事件呀?
- 请问:如何改变listbox,listview控件的被选择的当前列的颜色?
- 263zyf(控件)请进来,有分!
- 这条SQL怎么写,来者有分!
- dll问答
http://www.gbnis.com/read_file.asp?id=3443
tring, byval y as string, byval z as string, byval xin as string, byva
l qdata as string, byval rots as integer)
md5f = bigmod32add(rotleft(bigmod32add(bigmod32add(w, tempstr), bi
gmod32add(xin, qdata)), rots), x)
end function sub md5f1(w as string, byval x as string, byval y as string, byval z a
s string, byval xin as string, byval qdata as string, byval rots as in
teger)
dim tempstr as string tempstr = bigxor(z, bigand(x, bigxor(y, z)))
w = md5f(tempstr, w, x, y, z, xin, qdata, rots)
end sub sub md5f2(w as string, byval x as string, byval y as string, byval z a
s string, byval xin as string, byval qdata as string, byval rots as in
teger)
dim tempstr as string tempstr = bigxor(y, bigand(z, bigxor(x, y)))
w = md5f(tempstr, w, x, y, z, xin, qdata, rots)
end sub sub md5f3(w as string, byval x as string, byval y as string, byval z a
s string, byval xin as string, byval qdata as string, byval rots as in
teger)
dim tempstr as string tempstr = bigxor(x, bigxor(y, z))
w = md5f(tempstr, w, x, y, z, xin, qdata, rots)
end sub sub md5f4(w as string, byval x as string, byval y as string, byval z a
s string, byval xin as string, byval qdata as string, byval rots as in
teger)
dim tempstr as string tempstr = bigxor(y, bigor(x, bignot(z)))
w = md5f(tempstr, w, x, y, z, xin, qdata, rots)
end sub function md5_calc(byval hashthis as string) as string
redim buf(0 to 3) as string
redim xin(0 to 15) as string
dim tempnum as integer, tempnum2 as integer, loopit as integer, loopou
ter as integer, loopinner as integer
dim a as string, b as string, c as string, d as string ' add padding tempnum = 8 * len(hashthis)
hashthis = hashthis + chr$(128) 'add binary 10000000
tempnum2 = 56 - len(hashthis) mod 64 if tempnum2 < 0 then
tempnum2 = 64 + tempnum2
end if hashthis = hashthis + string$(tempnum2, chr$(0)) for loopit = 1 to 8
hashthis = hashthis + chr$(tempnum mod 256)
tempnum = tempnum - tempnum mod 256
tempnum = tempnum / 256
next loopit ' set magic numbers
buf(0) = "67452301"
buf(1) = "efcdab89"
buf(2) = "98badcfe"
buf(3) = "10325476" ' for each 512 bit section
for loopouter = 0 to len(hashthis) / 64 - 1
a = buf(0)
b = buf(1)
c = buf(2)
d = buf(3) ' get the 512 bits
for loopit = 0 to 15
xin(loopit) = ""
for loopinner = 1 to 4
xin(loopit) = hex$(asc(mid$(hashthis, 64 * loopouter +
4 * loopit + loopinner, 1))) + xin(loopit)
if len(xin(loopit)) mod 2 then xin(loopit) = "0" + xin
(loopit)
next loopinner
next loopit ' round 1
md5f1 a, b, c, d, xin(0), "d76aa478", 7
md5f1 d, a, b, c, xin(1), "e8c7b756", 12
md5f1 c, d, a, b, xin(2), "242070db", 17
md5f1 b, c, d, a, xin(3), "c1bdceee", 22
md5f1 a, b, c, d, xin(4), "f57c0faf", 7
md5f1 d, a, b, c, xin(5), "4787c62a", 12
md5f1 c, d, a, b, xin(6), "a8304613", 17
md5f1 b, c, d, a, xin(7), "fd469501", 22
md5f1 a, b, c, d, xin(8), "698098d8", 7
md5f1 d, a, b, c, xin(9), "8b44f7af", 12
md5f1 c, d, a, b, xin(10), "ffff5bb1", 17
md5f1 b, c, d, a, xin(11), "895cd7be", 22
md5f1 a, b, c, d, xin(12), "6b901122", 7
md5f1 d, a, b, c, xin(13), "fd987193", 12
md5f1 c, d, a, b, xin(14), "a679438e", 17
md5f1 b, c, d, a, xin(15), "49b40821", 22 ' round 2
md5f2 a, b, c, d, xin(1), "f61e2562", 5
md5f2 d, a, b, c, xin(6), "c040b340", 9
md5f2 c, d, a, b, xin(11), "265e5a51", 14
md5f2 b, c, d, a, xin(0), "e9b6c7aa", 20
md5f2 a, b, c, d, xin(5), "d62f105d", 5
md5f2 d, a, b, c, xin(10), "02441453", 9
md5f2 c, d, a, b, xin(15), "d8a1e681", 14
md5f2 b, c, d, a, xin(4), "e7d3fbc8", 20
md5f2 a, b, c, d, xin(9), "21e1cde6", 5
md5f2 d, a, b, c, xin(14), "c33707d6", 9
md5f2 c, d, a, b, xin(3), "f4d50d87", 14
md5f2 b, c, d, a, xin(8), "455a14ed", 20
md5f2 a, b, c, d, xin(13), "a9e3e905", 5
md5f2 d, a, b, c, xin(2), "fcefa3f8", 9
md5f2 c, d, a, b, xin(7), "676f02d9", 14
md5f2 b, c, d, a, xin(12), "8d2a4c8a", 20 ' round 3
md5f3 a, b, c, d, xin(5), "fffa3942", 4
md5f3 d, a, b, c, xin(8), "8771f681", 11
md5f3 c, d, a, b, xin(11), "6d9d6122", 16
md5f3 b, c, d, a, xin(14), "fde5380c", 23
md5f3 a, b, c, d, xin(1), "a4beea44", 4
md5f3 d, a, b, c, xin(4), "4bdecfa9", 11
md5f3 c, d, a, b, xin(7), "f6bb4b60", 16
md5f3 b, c, d, a, xin(10), "bebfbc70", 23
md5f3 a, b, c, d, xin(13), "289b7ec6", 4
md5f3 d, a, b, c, xin(0), "e27fa", 11
md5f3 c, d, a, b, xin(3), "d4ef3085", 16
md5f3 b, c, d, a, xin(6), "04881d05", 23
md5f3 a, b, c, d, xin(9), "d9d4d039", 4
md5f3 d, a, b, c, xin(12), "e6db99e5", 11
md5f3 c, d, a, b, xin(15), "1fa27cf8", 16
md5f3 b, c, d, a, xin(2), "c4ac5665", 23 ' round 4
md5f4 a, b, c, d, xin(0), "f4292244", 6
md5f4 d, a, b, c, xin(7), "432aff97", 10
md5f4 c, d, a, b, xin(14), "ab9423a7", 15
md5f4 b, c, d, a, xin(5), "fc93a039", 21
md5f4 a, b, c, d, xin(12), "655b59c3", 6
md5f4 d, a, b, c, xin(3), "8f0ccc92", 10
md5f4 c, d, a, b, xin(10), "ffeff47d", 15
md5f4 b, c, d, a, xin(1), "85845dd1", 21
md5f4 a, b, c, d, xin(8), "6fa87e4f", 6
md5f4 d, a, b, c, xin(15), "fe2ce6e0", 10
md5f4 c, d, a, b, xin(6), "a3014314", 15
md5f4 b, c, d, a, xin(13), "4e0811a1", 21
md5f4 a, b, c, d, xin(4), "f7537e82", 6
md5f4 d, a, b, c, xin(11), "bd3af235", 10
md5f4 c, d, a, b, xin(2), "2ad7d2bb", 15
md5f4 b, c, d, a, xin(9), "eb86d391", 21 buf(0) = bigadd(buf(0), a)
buf(1) = bigadd(buf(1), b)
buf(2) = bigadd(buf(2), c)
buf(3) = bigadd(buf(3), d)
next loopouter ' extract md5hash
hashthis = ""
for loopit = 0 to 3
for loopinner = 3 to 0 step -1
hashthis = hashthis + chr(val("&h" + mid$(buf(loopit), 1 +
2 * loopinner, 2)))
next loopinner
next loopit ' and return it
md5_calc = hashthis
end function
s string
bigmod32add = right$(bigadd(value1, value2), 8)
end function public function bigadd(byval value1 as string, byval value2 as string)
as string
dim valueans as string
dim loopit as integer, tempnum as integer tempnum = len(value1) - len(value2)
if tempnum < 0 then
value1 = space$(abs(tempnum)) + value1
elseif tempnum > 0 then
value2 = space$(abs(tempnum)) + value2
end if tempnum = 0
for loopit = len(value1) to 1 step -1
tempnum = tempnum + val("&h" + mid$(value1, loopit, 1)) + val(
"&h" + mid$(value2, loopit, 1))
valueans = hex$(tempnum mod 16) + valueans
tempnum = int(tempnum / 16)
next loopit if tempnum <> 0 then
valueans = hex$(tempnum) + valueans
end if bigadd = right(valueans, 8)
end function public function rotleft(byval value1 as string, byval rots as integer)
as string
dim tempstr as string
dim loopit as integer, loopinner as integer
dim tempnum as integer rots = rots mod 32
if rots = 0 then
rotleft = value1
exit function
end if value1 = right$(value1, 8)
tempstr = string$(8 - len(value1), "0") + value1
value1 = "" ' convert to binary
for loopit = 1 to 8
tempnum = val("&h" + mid$(tempstr, loopit, 1))
for loopinner = 3 to 0 step -1
if tempnum and 2 ^ loopinner then
value1 = value1 + "1"
else
value1 = value1 + "0"
end if
next loopinner
next loopit
tempstr = mid$(value1, rots + 1) + left$(value1, rots) ' and convert back to hex
value1 = ""
for loopit = 0 to 7
tempnum = 0
for loopinner = 0 to 3
if val(mid$(tempstr, 4 * loopit + loopinner + 1, 1)) then tempnum = tempnum + 2 ^ (3 - loopinner)
end if
next loopinner
value1 = value1 + hex$(tempnum)
next loopit rotleft = right(value1, 8)
end function function bigand(byval value1 as string, byval value2 as string) as str
ing
dim valueans as string
dim loopit as integer, tempnum as integer tempnum = len(value1) - len(value2)
if tempnum < 0 then
value2 = mid$(value2, abs(tempnum) + 1)
elseif tempnum > 0 then
value1 = mid$(value1, tempnum + 1)
end if for loopit = 1 to len(value1)
valueans = valueans + hex$(val("&h" + mid$(value1, loopit, 1))
and val("&h" + mid$(value2, loopit, 1)))
next loopit bigand = valueans
end function function bignot(byval value1 as string) as string
dim valueans as string
dim loopit as integer value1 = right$(value1, 8)
value1 = string$(8 - len(value1), "0") + value1
for loopit = 1 to 8
valueans = valueans + hex$(15 xor val("&h" + mid$(value1, loop
it, 1)))
next loopit bignot = valueans
end function function bigor(byval value1 as string, byval value2 as string) as stri
ng
dim valueans as string
dim loopit as integer, tempnum as integer tempnum = len(value1) - len(value2)
if tempnum < 0 then
valueans = left$(value2, abs(tempnum))
value2 = mid$(value2, abs(tempnum) + 1)
elseif tempnum > 0 then
valueans = left$(value1, abs(tempnum))
value1 = mid$(value1, tempnum + 1)
end if for loopit = 1 to len(value1)
valueans = valueans + hex$(val("&h" + mid$(value1, loopit, 1))
or val("&h" + mid$(value2, loopit, 1)))
next loopit bigor = valueans
end function function bigxor(byval value1 as string, byval value2 as string) as str
ing
dim valueans as string
dim loopit as integer, tempnum as integer tempnum = len(value1) - len(value2)
if tempnum < 0 then
valueans = left$(value2, abs(tempnum))
value2 = mid$(value2, abs(tempnum) + 1)
elseif tempnum > 0 then
valueans = left$(value1, abs(tempnum))
value1 = mid$(value1, tempnum + 1)
end if for loopit = 1 to len(value1)
valueans = valueans + hex$(val("&h" + mid$(value1, loopit, 1))
xor val("&h" + mid$(value2, loopit, 1)))
next loopit bigxor = right(valueans, 8)
end function