[请益] Pack('H*') in classic asp

楼主: sliceart (art)   2015-03-27 22:36:03
想请问若要在ASP中实作PACK()的话该怎么做呢?
主要是为了将pack('H*',md5($str))实作在ASP中
在ASP内我先把md5的32个位元两两一组
再把这16组字串转成数字,如33转成51
然后再用chr()转成ASCII,最后将这16个字符加起来
我这样测试了几笔资料,看起来是好像显示出来的,PHP跟ASP都一样
但是将解析出来的字串再透过MD5比对,PHP跟ASP的就天差地远了
请问有没有高手可解惑.....
谢谢
function PHP_PACK(str)
dim i , rtn , tmpA,tmpB
rtn = ""
For i = 1 to len(str) step 2
tmpA = mid(str,i,1)
tmpB = mid(str,i+1,1)
num = HexToTen(tmpA)*16+HexToTen(tmpB)
'response.write num&":"&chr(num)&"<br/>"
rtn = rtn & chr(num)
next
'response.write rtn & ":"&md5(rtn)&"<br/>"
PHP_PACK=rtn
end function
function HexToTen(str)
select case lcase(str)
case "1":rtn = 1
case "2":rtn = 2
case "3":rtn = 3
case "4":rtn = 4
case "5":rtn = 5
case "6":rtn = 6
case "7":rtn = 7
case "8":rtn = 8
case "9":rtn = 9
case "a":rtn = 10
case "b":rtn = 11
case "c":rtn = 12
case "d":rtn = 13
case "e":rtn = 14
case "f":rtn = 15
end select
HexToTen = rtn
end function

Links booklink

Contact Us: admin [ a t ] ucptt.com