日期:2014-05-16  浏览次数:21013 次

新手求助 MD5加密
我这边有一个查询用户信息接口,http://x/api/userinfo.html
传递参数 username , pwd
但是接口说明:用户密码进行MD5加密,公钥为用户名。

个人了解MD5是散列算法,那是不是不存在公钥的概念,那么公钥做哪里使用?WEB初学,求教。 
------解决方案--------------------
MD5加密算法 ASP版 
 
 
 
  
<% 
private const bits_to_a_byte = 8 
private const bytes_to_a_word = 4 
private const bits_to_a_word = 32 
private m_lonbits(30) 
private m_l2power(30)

private function lshift(lvalue, 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 m_l2power(31 - ishiftbits)) then 
lshift = ((lvalue and m_lonbits(31 - (ishiftbits + 1))) * m_l2power(ishiftbits)) or &h80000000 
else 
lshift = ((lvalue and m_lonbits(31 - ishiftbits)) * m_l2power(ishiftbits)) 
end if 
end function

private function rshift(lvalue, 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) \ m_l2power(ishiftbits)

if (lvalue and &h80000000) then 
rshift = (rshift or (&h40000000 \ m_l2power(ishiftbits - 1))) 
end if 
end function

private function rotateleft(lvalue, ishiftbits) 
rotateleft = lshift(lvalue, ishiftbits) or rshift(lvalue, (32 - ishiftbits)) 
end function

private function addunsigned(lx, 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 
elseif lx4 or ly4 then 
if lresult and &h40000000 then 
lresult = lresult xor &hc0000000 xor lx8 xor ly8 
else 
lresult = lresult xor &h40000000 xor lx8 xor ly8 
end if 
else