asp 一些支付接口
程序员文章站
2022-06-24 16:21:53
99bill: 1.md5.asp 复制代码 代码如下: <% ''''''''' ' @description: 快钱网关接口范例 ' @copyright (c)...
99bill:
1.md5.asp
<%
'''''''''
' @description: 快钱网关接口范例
' @copyright (c) 上海快钱信息服务有限公司
' @version 2.0
'''''''''
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
lresult = lresult xor lx8 xor ly8
end if
addunsigned = lresult
end function
private function md5_f(x, y, z)
md5_f = (x and y) or ((not x) and z)
end function
private function md5_g(x, y, z)
md5_g = (x and z) or (y and (not z))
end function
private function md5_h(x, y, z)
md5_h = (x xor y xor z)
end function
private function md5_i(x, y, z)
md5_i = (y xor (x or (not z)))
end function
private sub md5_ff(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_f(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_gg(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_g(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_hh(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_h(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_ii(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_i(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private function converttowordarray(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 wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = rshift(lvalue, lcount * bits_to_a_byte) and m_lonbits(bits_to_a_byte - 1)
wordtohex = wordtohex & right("0" & hex(lbyte), 2)
next
end function
public function md5(smessage)
m_lonbits(0) = clng(1)
m_lonbits(1) = clng(3)
m_lonbits(2) = clng(7)
m_lonbits(3) = clng(15)
m_lonbits(4) = clng(31)
m_lonbits(5) = clng(63)
m_lonbits(6) = clng(127)
m_lonbits(7) = clng(255)
m_lonbits(8) = clng(511)
m_lonbits(9) = clng(1023)
m_lonbits(10) = clng(2047)
m_lonbits(11) = clng(4095)
m_lonbits(12) = clng(8191)
m_lonbits(13) = clng(16383)
m_lonbits(14) = clng(32767)
m_lonbits(15) = clng(65535)
m_lonbits(16) = clng(131071)
m_lonbits(17) = clng(262143)
m_lonbits(18) = clng(524287)
m_lonbits(19) = clng(1048575)
m_lonbits(20) = clng(2097151)
m_lonbits(21) = clng(4194303)
m_lonbits(22) = clng(8388607)
m_lonbits(23) = clng(16777215)
m_lonbits(24) = clng(33554431)
m_lonbits(25) = clng(67108863)
m_lonbits(26) = clng(134217727)
m_lonbits(27) = clng(268435455)
m_lonbits(28) = clng(536870911)
m_lonbits(29) = clng(1073741823)
m_lonbits(30) = clng(2147483647)
m_l2power(0) = clng(1)
m_l2power(1) = clng(2)
m_l2power(2) = clng(4)
m_l2power(3) = clng(8)
m_l2power(4) = clng(16)
m_l2power(5) = clng(32)
m_l2power(6) = clng(64)
m_l2power(7) = clng(128)
m_l2power(8) = clng(256)
m_l2power(9) = clng(512)
m_l2power(10) = clng(1024)
m_l2power(11) = clng(2048)
m_l2power(12) = clng(4096)
m_l2power(13) = clng(8192)
m_l2power(14) = clng(16384)
m_l2power(15) = clng(32768)
m_l2power(16) = clng(65536)
m_l2power(17) = clng(131072)
m_l2power(18) = clng(262144)
m_l2power(19) = clng(524288)
m_l2power(20) = clng(1048576)
m_l2power(21) = clng(2097152)
m_l2power(22) = clng(4194304)
m_l2power(23) = clng(8388608)
m_l2power(24) = clng(16777216)
m_l2power(25) = clng(33554432)
m_l2power(26) = clng(67108864)
m_l2power(27) = clng(134217728)
m_l2power(28) = clng(268435456)
m_l2power(29) = clng(536870912)
m_l2power(30) = clng(1073741824)
dim x
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
x = converttowordarray(smessage)
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x) step 16
aa = a
bb = b
cc = c
dd = d
md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
md5_ff c, d, a, b, x(k + 2), s13, &h242070db
md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
md5_gg d, a, b, c, x(k + 10), s22, &h2441453
md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = addunsigned(a, aa)
b = addunsigned(b, bb)
c = addunsigned(c, cc)
d = addunsigned(d, dd)
next
md5 = lcase(wordtohex(a) & wordtohex(b) & wordtohex(c) & wordtohex(d)) '32byte
'md5 = lcase(wordtohex(b) & wordtohex(c)) 'i crop this to fit 16byte database password :d
end function
%>
2.send.asp
<!--#include file="md5.asp"-->
<%
'''''''''
' @description: 快钱网关接口范例
' @copyright (c) 上海快钱信息服务有限公司
' @version 2.0
'''''''''
merchant_id = request("cid") '''商户编号
merchant_key = request("mykey") '''商户密钥
orderid = request("orderid") '''订单编号
amount = request("totalmoney") '''订单金额
curr = "1" '''货币类型,1为人民币
issupportdes = "2" '''是否安全校验,2为必校验,推荐
merchant_url = "" '''支付结果返回地址
pname = request("pname") '''支付人姓名
commodity_info = "" '''商品信息
merchant_param = "" '''商户私有参数
pemail="" '''传递email到快钱网关页面
pid="" '''代理/合作伙伴商户编号
'''生成加密串,注意顺序
scrtstr="merchant_id=" & merchant_id & "&orderid=" & orderid & "&amount=" & amount & "&merchant_url=" & merchant_url & "&merchant_key=" & merchant_key
mac=ucase(md5(scrtstr))
%>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
<head>
<title>快钱99bill</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" >
</head>
<body onload="javascript:document.frm.submit()">
<form name="frm" method="post" action="https://www.99bill.com/webapp/receivemerchantinfoaction.do">
<input name="merchant_id" type="hidden" value="<%=merchant_id%>">
<input name="orderid" type="hidden" value="<%=orderid%>">
<input name="amount" type="hidden" value="<%=amount%>">
<input name="currency" type="hidden" value="<%=curr%>">
<input name="issupportdes" type="hidden" value="<%=issupportdes%>">
<input name="mac" type="hidden" value="<%=mac%>">
<input name="merchant_url" type="hidden" value="<%=merchant_url%>">
<input name="pname" type="hidden" value="<%=pname%>">
<input name="commodity_info" type="hidden" value="<%=commodity_info%>">
<input name="merchant_param" type="hidden" value="<%=merchant_param%>">
<input name="pemail" type="hidden" value="<%=pemail%>">
<input name="pid" type="hidden" value="<%=pid%>">
</form>
</body>
</html>
alipay
1.alipay_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 str2bin(varstr)
dim varasc
dim i
dim varchar
dim varlow
dim varhigh
str2bin=""
for i=1 to len(varstr)
varchar=mid(varstr,i,1)
varasc = asc(varchar)
if varasc<0 then
varasc = varasc + 65535
end if
if varasc>255 then
varlow = left(hex(asc(varchar)),2)
varhigh = right(hex(asc(varchar)),2)
str2bin = str2bin & chrb("&h" & varlow) & chrb("&h" & varhigh)
else
str2bin = str2bin & chrb(ascb(varchar))
end if
next
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
lresult = lresult xor lx8 xor ly8
end if
addunsigned = lresult
end function
private function md5_f(x, y, z)
md5_f = (x and y) or ((not x) and z)
end function
private function md5_g(x, y, z)
md5_g = (x and z) or (y and (not z))
end function
private function md5_h(x, y, z)
md5_h = (x xor y xor z)
end function
private function md5_i(x, y, z)
md5_i = (y xor (x or (not z)))
end function
private sub md5_ff(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_f(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_gg(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_g(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_hh(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_h(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_ii(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_i(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private function converttowordarray(smessage)
dim lmessagelength
dim lnumberofwords
dim lwordarray()
dim lbyteposition
dim lbytecount
dim lwordcount
const modulus_bits = 512
const congruent_bits = 448
lmessagelength = lenb(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(ascb(midb(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 wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = rshift(lvalue, lcount * bits_to_a_byte) and m_lonbits(bits_to_a_byte - 1)
wordtohex = wordtohex & right("0" & hex(lbyte), 2)
next
end function
public function md5(smessage)
m_lonbits(0) = clng(1)
m_lonbits(1) = clng(3)
m_lonbits(2) = clng(7)
m_lonbits(3) = clng(15)
m_lonbits(4) = clng(31)
m_lonbits(5) = clng(63)
m_lonbits(6) = clng(127)
m_lonbits(7) = clng(255)
m_lonbits(8) = clng(511)
m_lonbits(9) = clng(1023)
m_lonbits(10) = clng(2047)
m_lonbits(11) = clng(4095)
m_lonbits(12) = clng(8191)
m_lonbits(13) = clng(16383)
m_lonbits(14) = clng(32767)
m_lonbits(15) = clng(65535)
m_lonbits(16) = clng(131071)
m_lonbits(17) = clng(262143)
m_lonbits(18) = clng(524287)
m_lonbits(19) = clng(1048575)
m_lonbits(20) = clng(2097151)
m_lonbits(21) = clng(4194303)
m_lonbits(22) = clng(8388607)
m_lonbits(23) = clng(16777215)
m_lonbits(24) = clng(33554431)
m_lonbits(25) = clng(67108863)
m_lonbits(26) = clng(134217727)
m_lonbits(27) = clng(268435455)
m_lonbits(28) = clng(536870911)
m_lonbits(29) = clng(1073741823)
m_lonbits(30) = clng(2147483647)
m_l2power(0) = clng(1)
m_l2power(1) = clng(2)
m_l2power(2) = clng(4)
m_l2power(3) = clng(8)
m_l2power(4) = clng(16)
m_l2power(5) = clng(32)
m_l2power(6) = clng(64)
m_l2power(7) = clng(128)
m_l2power(8) = clng(256)
m_l2power(9) = clng(512)
m_l2power(10) = clng(1024)
m_l2power(11) = clng(2048)
m_l2power(12) = clng(4096)
m_l2power(13) = clng(8192)
m_l2power(14) = clng(16384)
m_l2power(15) = clng(32768)
m_l2power(16) = clng(65536)
m_l2power(17) = clng(131072)
m_l2power(18) = clng(262144)
m_l2power(19) = clng(524288)
m_l2power(20) = clng(1048576)
m_l2power(21) = clng(2097152)
m_l2power(22) = clng(4194304)
m_l2power(23) = clng(8388608)
m_l2power(24) = clng(16777216)
m_l2power(25) = clng(33554432)
m_l2power(26) = clng(67108864)
m_l2power(27) = clng(134217728)
m_l2power(28) = clng(268435456)
m_l2power(29) = clng(536870912)
m_l2power(30) = clng(1073741824)
dim x
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
x = converttowordarray(str2bin(smessage))
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x) step 16
aa = a
bb = b
cc = c
dd = d
md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
md5_ff c, d, a, b, x(k + 2), s13, &h242070db
md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
md5_gg d, a, b, c, x(k + 10), s22, &h2441453
md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = addunsigned(a, aa)
b = addunsigned(b, bb)
c = addunsigned(c, cc)
d = addunsigned(d, dd)
next
md5 = lcase(wordtohex(a) & wordtohex(b) & wordtohex(c) & wordtohex(d))
end function
%>
2.alipay_payto.asp
<!--#include file="alipay_md5.asp"-->
<%
class creatalipayitemurl
'获得最终的购买url
public function creatalipayitemurl(t1,t4,t5,service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url,key)
dim itemurl
dim interface_url,imgsrc,imgtitle
'初始化各必要变量
interface_url = t1 '支付接口
imgsrc = t4 '支付宝按钮图片
imgtitle = t5 '按钮悬停说明
'add by sunzhizhi 2006-5-10
mystr = array("service="&service,"agent="&agent,"partner="&partner,"subject="&subject,"body="&body,"out_trade_no="&out_trade_no,"price="&price,"discount="&discount,"show_url="&show_url,"quantity="&quantity,"payment_type="&payment_type,"logistics_type="&logistics_type,"logistics_fee="&logistics_fee,"logistics_payment="&logistics_payment,"logistics_type_1="&logistics_type_1,"logistics_fee_1="&logistics_fee_1,"logistics_payment_1="&logistics_payment_1,"seller_email="&seller_email,"notify_url="¬ify_url,"return_url="&return_url)
count=ubound(mystr)
for i = count to 0 step -1
minmax = mystr( 0 )
minmaxslot = 0
for j = 1 to i
mark = (mystr( j ) > minmax)
if mark then
minmax = mystr( j )
minmaxslot = j
end if
next
if minmaxslot <> i then
temp = mystr( minmaxslot )
mystr( minmaxslot ) = mystr( i )
mystr( i ) = temp
end if
next
for j = 0 to count step 1
value = split(mystr( j ), "=")
if value(1)<>"" then
if j=count then
md5str= md5str&mystr( j )
else
md5str= md5str&mystr( j )&"&"
end if
end if
next
md5str=md5str&key
' response.write md5str
sign=md5(md5str)
itemurl = itemurl&interface_url
for j = 0 to count step 1
value = split(mystr( j ), "=")
if value(1)<>"" then
itemurl= itemurl&mystr( j )&"&"
end if
next
itemurl = itemurl&"sign="&sign&"&sign_type="&sign_type
'response.write itemurl
creatalipayitemurl = itemurl
end function
public function get_alipaybuttonurl(itemurl,imgtitle,imgsrc)
dim responsetext1
responsetext1 = responsetext1 & "<a href="" & itemurl & "" href="" & itemurl & "" target='_blank'>" '购买网址
responsetext1 = responsetext1 & "<img alt='" & imgtitle & "' src="" " src="" "图片说明
responsetext1 = responsetext1 & imgsrc '图片地址
responsetext1 = responsetext1 & "' align='absmiddle' border='0'/></a>"
get_alipaybuttonurl=responsetext1
end function
end class
%>
3.send1.asp
<!--#include file="alipay_payto.asp"-->
<%
cid = request("cid") '''商户编号
response.write cid&"<br>"
meykey = request("mykey") '''商户密钥
response.write meykey&"<br>"
out_trade_no = request("orderid") '''订单编号
response.write out_trade_no&"<br>"
totalmoeny = request("totalmoney") '''订单金额
response.write totalmoeny&"<br>"
partnerid=request("other1")
response.write partnerid&"<br>"
'response.end
dim service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url
dim t1,t4,t5,key
dim alipayobj,itemurl
t1 = "https://www.alipay.com/cooperate/gateway.do?" '支付接口
t4 = "images/alipay_bwrx.gif" '支付宝按钮图片
t5 = "推荐使用支付宝付款" '按钮悬停说明
service = "trade_create_by_buyer" '"trade_create_by_buyer"
agent = partnerid '合作厂商id
partner = partnerid 'partner合作伙伴id(必须填)
sign_type = "md5"
subject = "" '商品名称
body = "" 'body 商品描述
out_trade_no = trim(replace(out_trade_no,":","")) '客户网站订单号,(现取系统时间,可改成网站自己的变量)
price = totalmoeny 'price商品单价 0.01~50000.00
discount = "0" '商品折扣
show_url = "" '商品展示地址(可以直接写网站首页网址)
quantity = "" '商品数量
payment_type = "1" '支付类型,(1代表商品购买)
logistics_type = "" '物流种类(快递)
logistics_fee = "" '物流费用
logistics_payment = "" '物流费用承担(卖家付)
logistics_type_1 = ""
logistics_fee_1 = ""
logistics_payment_1 = "" '物流费用承担(买家付)
seller_email = cid '(必须填)
key = mykey '(必须填)
notify_url= "" '服务器通知url(不使用,请不要注释或者删除此参数,不用传递给支付宝系统,alipay_notify.asp文件所在路经)
return_url= "" '服务器通知url(不使用,请不要注释或者删除此参数,不用传递给支付宝系统,alipay_notify.asp文件所在路经)
set alipayobj = new creatalipayitemurl
itemurl=alipayobj.creatalipayitemurl(t1,t4,t5,service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url,key)
response.redirect itemurl
response.end
%>
4.send.asp
<!--#include file="alipay_payto.asp"-->
<%
cid = request("cid") '''商户编号
response.write cid&"<br>"
meykey = request("mykey") '''商户密钥
response.write meykey&"<br>"
orderid = request("orderid") '''订单编号
response.write orderid &"<br>"
totalmoeny = request("totalmoney") '''订单金额
response.write totalmoeny&"<br>"
partnerid=request("other1")
response.write partnerid&"<br>"
other2=request("other2")
other3=request("other3")
'response.end
dim service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url
dim t1,t4,t5,key
dim alipayobj,itemurl
t1 = "https://www.alipay.com/cooperate/gateway.do?" '支付接口
t4 = "images/alipay_bwrx.gif" '支付宝按钮图片
t5 = "推荐使用支付宝付款" '按钮悬停说明
service = "trade_create_by_buyer"
agent = partnerid '合作厂商id
partner = partnerid 'partner合作伙伴id(必须填)
sign_type = "md5"
subject = "商品" '商品名称
body = "" 'body 商品描述
out_trade_no = orderid '客户网站订单号,(现取系统时间,可改成网站自己的变量)
price = totalmoeny 'price商品单价 0.01~50000.00
discount = "0" '商品折扣
show_url = "" '商品展示地址(可以直接写网站首页网址)
quantity = "1" '商品数量
payment_type = "1" '支付类型,(1代表商品购买)
logistics_type = "express" '物流种类(快递)
logistics_fee = other3 '物流费用
logistics_payment = other2 '物流费用承担(卖家付)
logistics_type_1 = ""
logistics_fee_1 = ""
logistics_payment_1 = "" '物流费用承担(买家付)
seller_email = cid '(必须填)
key = meykey '(必须填)
notify_url= "" '服务器通知url(不使用,请不要注释或者删除此参数,不用传递给支付宝系统,alipay_notify.asp文件所在路经)
return_url= "" '服务器通知url(不使用,请不要注释或者删除此参数,不用传递给支付宝系统,alipay_notify.asp文件所在路经)
set alipayobj = new creatalipayitemurl
itemurl=alipayobj.creatalipayitemurl(t1,t4,t5,service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url,key)
response.redirect itemurl
response.end
%>
chinabank
1.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
lresult = lresult xor lx8 xor ly8
end if
addunsigned = lresult
end function
private function md5_f(x, y, z)
md5_f = (x and y) or ((not x) and z)
end function
private function md5_g(x, y, z)
md5_g = (x and z) or (y and (not z))
end function
private function md5_h(x, y, z)
md5_h = (x xor y xor z)
end function
private function md5_i(x, y, z)
md5_i = (y xor (x or (not z)))
end function
private sub md5_ff(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_f(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_gg(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_g(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_hh(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_h(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_ii(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_i(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private function converttowordarray(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 wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = rshift(lvalue, lcount * bits_to_a_byte) and m_lonbits(bits_to_a_byte - 1)
wordtohex = wordtohex & right("0" & hex(lbyte), 2)
next
end function
public function md5(smessage)
m_lonbits(0) = clng(1)
m_lonbits(1) = clng(3)
m_lonbits(2) = clng(7)
m_lonbits(3) = clng(15)
m_lonbits(4) = clng(31)
m_lonbits(5) = clng(63)
m_lonbits(6) = clng(127)
m_lonbits(7) = clng(255)
m_lonbits(8) = clng(511)
m_lonbits(9) = clng(1023)
m_lonbits(10) = clng(2047)
m_lonbits(11) = clng(4095)
m_lonbits(12) = clng(8191)
m_lonbits(13) = clng(16383)
m_lonbits(14) = clng(32767)
m_lonbits(15) = clng(65535)
m_lonbits(16) = clng(131071)
m_lonbits(17) = clng(262143)
m_lonbits(18) = clng(524287)
m_lonbits(19) = clng(1048575)
m_lonbits(20) = clng(2097151)
m_lonbits(21) = clng(4194303)
m_lonbits(22) = clng(8388607)
m_lonbits(23) = clng(16777215)
m_lonbits(24) = clng(33554431)
m_lonbits(25) = clng(67108863)
m_lonbits(26) = clng(134217727)
m_lonbits(27) = clng(268435455)
m_lonbits(28) = clng(536870911)
m_lonbits(29) = clng(1073741823)
m_lonbits(30) = clng(2147483647)
m_l2power(0) = clng(1)
m_l2power(1) = clng(2)
m_l2power(2) = clng(4)
m_l2power(3) = clng(8)
m_l2power(4) = clng(16)
m_l2power(5) = clng(32)
m_l2power(6) = clng(64)
m_l2power(7) = clng(128)
m_l2power(8) = clng(256)
m_l2power(9) = clng(512)
m_l2power(10) = clng(1024)
m_l2power(11) = clng(2048)
m_l2power(12) = clng(4096)
m_l2power(13) = clng(8192)
m_l2power(14) = clng(16384)
m_l2power(15) = clng(32768)
m_l2power(16) = clng(65536)
m_l2power(17) = clng(131072)
m_l2power(18) = clng(262144)
m_l2power(19) = clng(524288)
m_l2power(20) = clng(1048576)
m_l2power(21) = clng(2097152)
m_l2power(22) = clng(4194304)
m_l2power(23) = clng(8388608)
m_l2power(24) = clng(16777216)
m_l2power(25) = clng(33554432)
m_l2power(26) = clng(67108864)
m_l2power(27) = clng(134217728)
m_l2power(28) = clng(268435456)
m_l2power(29) = clng(536870912)
m_l2power(30) = clng(1073741824)
dim x
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
x = converttowordarray(smessage)
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x) step 16
aa = a
bb = b
cc = c
dd = d
md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
md5_ff c, d, a, b, x(k + 2), s13, &h242070db
md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
md5_gg d, a, b, c, x(k + 10), s22, &h2441453
md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = addunsigned(a, aa)
b = addunsigned(b, bb)
c = addunsigned(c, cc)
d = addunsigned(d, dd)
next
md5 = lcase(wordtohex(a) & wordtohex(b) & wordtohex(c) & wordtohex(d)) '32byte
'md5 = lcase(wordtohex(b) & wordtohex(c)) 'i crop this to fit 16byte database password :d
end function
%>
2.send.asp
<!--
* ====================================================================
*
* send.asp 由网银在线技术支持提供
*
* 本页面接收来自上页所有订单信息,并提交支付订单到网线在线支付平台....
*
*
* ====================================================================
-->
<!--#include file="md5.asp"-->
<%
'****************************************
v_mid = request("cid") ' 商户号,这里为测试商户号20000400,替换为自己的商户号即可
v_url = "" ' 商户自定义返回接收支付结果的页面 receive.asp 为接收页面
' md5密钥要跟订单提交页相同,如send.asp里的 key = "test" ,修改""号内 test 为您的密钥
key = request("mykey") ' 如果您还没有设置md5密钥请登陆我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/
' 登陆后在上面的导航栏里可能找到“资料管理”,在资料管理的二级导航栏里有“md5密钥设置”
' 建议您设置一个16位以上的密钥或更高,密钥最多64位,但设置16位已经足够了
'****************************************%>
<%
if request("orderid")<>"" then '判断是否有传递订单号
v_oid = request("orderid")
else
curdate = now() ' 根据系统时间产生订单,格式:yyyymmdd-v_mid-hmmss
ymd = year(curdate)&month(curdate)&day(curdate) ' 年月日
hms = hour(curdate)&minute(curdate)&second(curdate) ' 分秒时
v_oid = ymd&"-"&v_mid&"-"&hms ' 推荐订单号构成格式为 年月日-商户号-小时分钟秒
end if
v_amount = request("totalmoney") ' 订单金额
v_moneytype = "cny" ' 币种
text = v_amount&v_moneytype&v_oid&v_mid&v_url&key ' 拼凑加密串
v_md5info=ucase(trim(md5(text))) ' 网银支付平台对md5值只认大写字符串,所以小写的md5值得转换为大写
'**********以下几项为可选信息,如果发送网银在线会保存此信息,使用和不使用都不影响支付!**************
v_rcvname = request("v_rcvname") ' 收货人
v_rcvaddr = request("v_rcvaddr") ' 收货地址
v_rcvtel = request("v_rcvtel") ' 收货人电话
v_rcvpost = request("v_rcvpost") ' 收货人邮编
v_rcvemail = request("v_rcvemail") ' 收货人邮件
v_rcvmobile = request("v_rcvmobile") ' 收货人手机号
v_ordername = request("v_ordername") ' 订货人姓名
v_orderaddr = request("v_orderaddr") ' 订货人地址
v_ordertel = request("v_ordertel") ' 订货人电话
v_orderpost = request("v_orderpost") ' 订货人邮编
v_orderemail = request("v_orderemail") ' 订货人邮件
v_ordermobile = request("v_ordermobile") ' 订货人手机号
remark1 = request("remark1") ' 备注字段1
remark2 = request("remark2") ' 备注字段2
%>
<!--以下信息为标准的 html 格式 + asp 语言 拼凑而成的 网银在线 支付接口标准演示页面 -->
<html>
<body onload="javascript:document.e_form.submit()">
<form action="https://pay3.chinabank.com.cn/paygate" method="post" name="e_form">
<!--以下几项为网上支付重要信息,信息必须正确无误,信息会影响支付进行!-->
<input type="hidden" name="v_md5info" value="<%=v_md5info%>" size="100">
<input type="hidden" name="v_mid" value="<%=v_mid%>">
<input type="hidden" name="v_oid" value="<%=v_oid%>">
<input type="hidden" name="v_amount" value="<%=v_amount%>">
<input type="hidden" name="v_moneytype" value="<%=v_moneytype%>">
<input type="hidden" name="v_url" value="<%=v_url%>">
<!--以下几项项为网上支付完成后,随支付反馈信息一同传给信息接收页,在传输过程中内容不会改变,如:receive.asp -->
<input type="hidden" name="remark1" value="<%=remark1%>">
<input type="hidden" name="remark2" value="<%=remark2%>">
<!--以下几项与网上支付货款无关,只是用来记录客户信息,可以不用,使用和不使用都不影响支付 -->
<input type="hidden" name="v_rcvname" value="<%=v_rcvname%>">
<input type="hidden" name="v_rcvaddr" value="<%=v_rcvaddr%>">
<input type="hidden" name="v_rcvtel" value="<%=v_rcvtel%>">
<input type="hidden" name="v_rcvpost" value="<%=v_rcvpost%>">
<input type="hidden" name="v_rcvemail" value="<%=v_rcvemail%>">
<input type="hidden" name="v_rcvmobile" value="<%=v_rcvmobile%>">
<input type="hidden" name="v_ordername" value="<%=v_ordername%>">
<input type="hidden" name="v_orderaddr" value="<%=v_orderaddr%>">
<input type="hidden" name="v_ordertel" value="<%=v_ordertel%>">
<input type="hidden" name="v_orderpost" value="<%=v_orderpost%>">
<input type="hidden" name="v_orderemail" value="<%=v_orderemail%>">
<input type="hidden" name="v_ordermobile" value="<%=v_ordermobile%>">
</form>
</body>
</html>
tenpay
1.asp_md5.asp
<%
private const asp_bits_to_a_byte = 8
private const asp_bytes_to_a_word = 4
private const asp_bits_to_a_word = 32
private asp_m_lonbits(30)
private asp_m_l2power(30)
private function asp_lshift(lvalue, ishiftbits)
if ishiftbits = 0 then
asp_lshift = lvalue
exit function
elseif ishiftbits = 31 then
if lvalue and 1 then
asp_lshift = &h80000000
else
asp_lshift = 0
end if
exit function
elseif ishiftbits < 0 or ishiftbits > 31 then
err.raise 6
end if
if (lvalue and asp_m_l2power(31 - ishiftbits)) then
asp_lshift = ((lvalue and asp_m_lonbits(31 - (ishiftbits + 1))) * asp_m_l2power(ishiftbits)) or &h80000000
else
asp_lshift = ((lvalue and asp_m_lonbits(31 - ishiftbits)) * asp_m_l2power(ishiftbits))
end if
end function
private function asp_str2binold(varstr)
asp_str2binold=""
for i=1 to len(varstr)
varchar=mid(varstr,i,1)
varasc = asc(varchar)
if varasc<0 then
varasc = varasc + 65535
end if
if varasc>255 then
varlow = left(hex(asc(varchar)),2)
varhigh = right(hex(asc(varchar)),2)
asp_str2binold = asp_str2binold & chrb("&h" & varlow) & chrb("&h" & varhigh)
else
asp_str2binold = asp_str2binold & chrb(ascb(varchar))
end if
next
end function
private function asp_str2bin(varstr)
asp_str2bin=""
for i=1 to len(varstr)
varchar=mid(varstr,i,1)
code = server.urlencode(varchar)
if len(code) = 1 then
asp_str2bin = asp_str2bin & chrb(ascb(code))
else
codearr = split(code,"%")
for j=1 to ubound(codearr)
asp_str2bin = asp_str2bin & chrb("&h" & codearr(j))
next
end if
next
end function
private function asp_rshift(lvalue, ishiftbits)
if ishiftbits = 0 then
asp_rshift = lvalue
exit function
elseif ishiftbits = 31 then
if lvalue and &h80000000 then
asp_rshift = 1
else
asp_rshift = 0
end if
exit function
elseif ishiftbits < 0 or ishiftbits > 31 then
err.raise 6
end if
asp_rshift = (lvalue and &h7ffffffe) \ asp_m_l2power(ishiftbits)
if (lvalue and &h80000000) then
asp_rshift = (asp_rshift or (&h40000000 \ asp_m_l2power(ishiftbits - 1)))
end if
end function
private function asp_rotateleft(lvalue, ishiftbits)
asp_rotateleft = asp_lshift(lvalue, ishiftbits) or asp_rshift(lvalue, (32 - ishiftbits))
end function
private function asp_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
lresult = lresult xor lx8 xor ly8
end if
asp_addunsigned = lresult
end function
private function asp_md5_f(x, y, z)
asp_md5_f = (x and y) or ((not x) and z)
end function
private function asp_md5_g(x, y, z)
asp_md5_g = (x and z) or (y and (not z))
end function
private function asp_md5_h(x, y, z)
asp_md5_h = (x xor y xor z)
end function
private function asp_md5_i(x, y, z)
asp_md5_i = (y xor (x or (not z)))
end function
private sub asp_md5_ff(a, b, c, d, x, s, ac)
a = asp_addunsigned(a, asp_addunsigned(asp_addunsigned(asp_md5_f(b, c, d), x), ac))
a = asp_rotateleft(a, s)
a = asp_addunsigned(a, b)
end sub
private sub asp_md5_gg(a, b, c, d, x, s, ac)
a = asp_addunsigned(a, asp_addunsigned(asp_addunsigned(asp_md5_g(b, c, d), x), ac))
a = asp_rotateleft(a, s)
a = asp_addunsigned(a, b)
end sub
private sub asp_md5_hh(a, b, c, d, x, s, ac)
a = asp_addunsigned(a, asp_addunsigned(asp_addunsigned(asp_md5_h(b, c, d), x), ac))
a = asp_rotateleft(a, s)
a = asp_addunsigned(a, b)
end sub
private sub asp_md5_ii(a, b, c, d, x, s, ac)
a = asp_addunsigned(a, asp_addunsigned(asp_addunsigned(asp_md5_i(b, c, d), x), ac))
a = asp_rotateleft(a, s)
a = asp_addunsigned(a, b)
end sub
private function asp_converttowordarray(smessage)
dim lmessagelength
dim lnumberofwords
dim lwordarray()
dim lbyteposition
dim lbytecount
dim lwordcount
const modulus_bits = 512
const congruent_bits = 448
lmessagelength = lenb(smessage)
lnumberofwords = (((lmessagelength + ((modulus_bits - congruent_bits) \ asp_bits_to_a_byte)) \ (modulus_bits \ asp_bits_to_a_byte)) + 1) * (modulus_bits \ asp_bits_to_a_word)
redim lwordarray(lnumberofwords - 1)
lbyteposition = 0
lbytecount = 0
do until lbytecount >= lmessagelength
lwordcount = lbytecount \ asp_bytes_to_a_word
lbyteposition = (lbytecount mod asp_bytes_to_a_word) * asp_bits_to_a_byte
lwordarray(lwordcount) = lwordarray(lwordcount) or asp_lshift(ascb(midb(smessage, lbytecount + 1, 1)), lbyteposition)
lbytecount = lbytecount + 1
loop
lwordcount = lbytecount \ asp_bytes_to_a_word
lbyteposition = (lbytecount mod asp_bytes_to_a_word) * asp_bits_to_a_byte
lwordarray(lwordcount) = lwordarray(lwordcount) or asp_lshift(&h80, lbyteposition)
lwordarray(lnumberofwords - 2) = asp_lshift(lmessagelength, 3)
lwordarray(lnumberofwords - 1) = asp_rshift(lmessagelength, 29)
asp_converttowordarray = lwordarray
end function
private function asp_wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = asp_rshift(lvalue, lcount * asp_bits_to_a_byte) and asp_m_lonbits(asp_bits_to_a_byte - 1)
asp_wordtohex = asp_wordtohex & right("0" & hex(lbyte), 2)
next
end function
public function asp_md5(smessage)
asp_m_lonbits(0) = clng(1)
asp_m_lonbits(1) = clng(3)
asp_m_lonbits(2) = clng(7)
asp_m_lonbits(3) = clng(15)
asp_m_lonbits(4) = clng(31)
asp_m_lonbits(5) = clng(63)
asp_m_lonbits(6) = clng(127)
asp_m_lonbits(7) = clng(255)
asp_m_lonbits(8) = clng(511)
asp_m_lonbits(9) = clng(1023)
asp_m_lonbits(10) = clng(2047)
asp_m_lonbits(11) = clng(4095)
asp_m_lonbits(12) = clng(8191)
asp_m_lonbits(13) = clng(16383)
asp_m_lonbits(14) = clng(32767)
asp_m_lonbits(15) = clng(65535)
asp_m_lonbits(16) = clng(131071)
asp_m_lonbits(17) = clng(262143)
asp_m_lonbits(18) = clng(524287)
asp_m_lonbits(19) = clng(1048575)
asp_m_lonbits(20) = clng(2097151)
asp_m_lonbits(21) = clng(4194303)
asp_m_lonbits(22) = clng(8388607)
asp_m_lonbits(23) = clng(16777215)
asp_m_lonbits(24) = clng(33554431)
asp_m_lonbits(25) = clng(67108863)
asp_m_lonbits(26) = clng(134217727)
asp_m_lonbits(27) = clng(268435455)
asp_m_lonbits(28) = clng(536870911)
asp_m_lonbits(29) = clng(1073741823)
asp_m_lonbits(30) = clng(2147483647)
asp_m_l2power(0) = clng(1)
asp_m_l2power(1) = clng(2)
asp_m_l2power(2) = clng(4)
asp_m_l2power(3) = clng(8)
asp_m_l2power(4) = clng(16)
asp_m_l2power(5) = clng(32)
asp_m_l2power(6) = clng(64)
asp_m_l2power(7) = clng(128)
asp_m_l2power(8) = clng(256)
asp_m_l2power(9) = clng(512)
asp_m_l2power(10) = clng(1024)
asp_m_l2power(11) = clng(2048)
asp_m_l2power(12) = clng(4096)
asp_m_l2power(13) = clng(8192)
asp_m_l2power(14) = clng(16384)
asp_m_l2power(15) = clng(32768)
asp_m_l2power(16) = clng(65536)
asp_m_l2power(17) = clng(131072)
asp_m_l2power(18) = clng(262144)
asp_m_l2power(19) = clng(524288)
asp_m_l2power(20) = clng(1048576)
asp_m_l2power(21) = clng(2097152)
asp_m_l2power(22) = clng(4194304)
asp_m_l2power(23) = clng(8388608)
asp_m_l2power(24) = clng(16777216)
asp_m_l2power(25) = clng(33554432)
asp_m_l2power(26) = clng(67108864)
asp_m_l2power(27) = clng(134217728)
asp_m_l2power(28) = clng(268435456)
asp_m_l2power(29) = clng(536870912)
asp_m_l2power(30) = clng(1073741824)
dim x
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
x = asp_converttowordarray(asp_str2bin(smessage))
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x) step 16
aa = a
bb = b
cc = c
dd = d
asp_md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
asp_md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
asp_md5_ff c, d, a, b, x(k + 2), s13, &h242070db
asp_md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
asp_md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
asp_md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
asp_md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
asp_md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
asp_md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
asp_md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
asp_md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
asp_md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
asp_md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
asp_md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
asp_md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
asp_md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
asp_md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
asp_md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
asp_md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
asp_md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
asp_md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
asp_md5_gg d, a, b, c, x(k + 10), s22, &h2441453
asp_md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
asp_md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
asp_md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
asp_md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
asp_md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
asp_md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
asp_md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
asp_md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
asp_md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
asp_md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
asp_md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
asp_md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
asp_md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
asp_md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
asp_md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
asp_md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
asp_md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
asp_md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
asp_md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
asp_md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
asp_md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
asp_md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
asp_md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
asp_md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
asp_md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
asp_md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
asp_md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
asp_md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
asp_md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
asp_md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
asp_md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
asp_md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
asp_md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
asp_md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
asp_md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
asp_md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
asp_md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
asp_md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
asp_md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
asp_md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
asp_md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
asp_md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = asp_addunsigned(a, aa)
b = asp_addunsigned(b, bb)
c = asp_addunsigned(c, cc)
d = asp_addunsigned(d, dd)
next
asp_md5 = lcase(asp_wordtohex(a) & asp_wordtohex(b) & asp_wordtohex(c) & asp_wordtohex(d))
end function
'使用方法是 md5 ("字符串") 下面是使用示范
'response.write "asp_md5('a')的加密结果为[" & asp_md5 ("a") & "]<br>"
'response.write "asp_md5('b')的加密结果为[" & asp_md5 ("b") & "]"
%>
2.send.asp
<!-- #include file="asp_md5.asp" -->
<%
dim merchantid
dim keyvalue
merchantid = request("cid") '''商户编号
keyvalue = request("mykey") '''商户密钥
orderid = request("orderid") '''订单编号
amount = request("totalmoney") '''订单金额
%>
<html>
<title>财付通支付</title>
<meta http-equiv="cache-control" content="no-cache"/>
<body onload="javascript:document.frm.submit()">
<% response.charset="gb2312" %>
<%
' 获取服务器日期,格式yyyymmdd
function cftgetserverdate
dim strtmp, iyear,imonth,idate
iyear = year(date)
imonth = month(date)
idate = day(date)
strtmp = cstr(iyear)
if imonth < 10 then
strtmp = strtmp & "0" & cstr(imonth)
else
strtmp = strtmp & cstr(imonth)
end if
if idate < 10 then
strtmp = strtmp & "0" & cstr(idate)
else
strtmp = strtmp & cstr(idate)
end if
cftgetserverdate = strtmp
end function
dim md5_sign
spid = merchantid ' 这里替换为您的实际商户号
sp_key = keyvalue ' sp_key是32位商户密钥, 请替换为您的实际密钥
' 下面是请求参数
cmdno = "1" ' 财付通支付为"1" (当前只支持 cmdno=1)
bill_date = cftgetserverdate ' 交易日期 (yyyymmdd)
bank_type = "0" ' 银行类型: 0 财付通
' 1001 招商银行
' 1002 中国工商银行
' 1003 中国建设银行
' 1004 上海浦东发展银行
' 1005 中国农业银行
' 1006 中国民生银行
' 1008 深圳发展银行
' 1009 兴业银行
desc = "" ' 商品名称
purchaser_id = "" ' 用户财付通帐号,如果没有可以置空
bargainor_id = spid ' 商户号
sp_billno = orderid ' 商户生成的订单号(最多32位)
' 重要:
' 交易单号(28位): 商户号(10位) + 日期(8位) + 流水号(10位), 必须按此格式生成, 且不能重复
' 如果sp_billno超过10位, 则截取其中的流水号部分加到transaction_id后部(不足10位左补0)
' 如果sp_billno不足10位, 则左补0, 加到transaction_id后部
transaction_id = spid & bill_date & "0000" & right(sp_billno,6)
total_fee = amount*100 ' 总金额, 分为单位
fee_type = "1" ' 货币类型: 1 – rmb(人民币) 2 - usd(美元) 3 - hkd(港币)
return_url = "" ' 财付通回调页面地址, (最长255个字符)
attach = "" ' 商户私有数据, 请求回调页面时原样返回
' 生成md5签名
sign_text = "cmdno=" & cmdno & "&date=" & bill_date & "&bargainor_id=" & bargainor_id &_
"&transaction_id=" & transaction_id & "&sp_billno=" & sp_billno &_
"&total_fee=" & total_fee & "&fee_type=" & fee_type & "&return_url=" & return_url &_
"&attach=" & attach & "&key=" & sp_key
md5_sign = ucase(asp_md5(sign_text)) ' 转换为大写
%>
<form name="frm" action="https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi">
<input type=hidden name="cmdno" value="<%=cmdno%>">
<input type=hidden name="date" value="<%=bill_date%>">
<input type=hidden name="bank_type" value="<%=bank_type%>">
<input type=hidden name="desc" value="<%=desc%>">
<input type=hidden name="purchaser_id" value="<%=purchaser_id%>">
<input type=hidden name="bargainor_id" value="<%=bargainor_id%>">
<input type=hidden name="transaction_id" value="<%=transaction_id%>">
<input type=hidden name="sp_billno" value="<%=sp_billno%>">
<input type=hidden name="total_fee" value="<%=total_fee%>">
<input type=hidden name="fee_type" value="<%=fee_type%>">
<input type=hidden name="return_url" value="<%=return_url%>">
<input type=hidden name="attach" value="<%=attach%>">
<input type=hidden name="sign" value="<%=md5_sign%>">
</form>
</body>
</html>
yeepay
1.hmac-md5.asp
<%
' md5 code:
' "derived from the rsa data security, inc. md5 message-digest algorithm,
' as set out in the memo rfc1321."
'
' heavily modified from http://www.frez.co.uk/
'
' hmac code:
' modified from authorizenet sample scripts
%>
<%
'
' constants used in this script
'
const bits_to_a_byte = 8
const bytes_to_a_word = 4
const bits_to_a_word = 32
dim m_lonbits(30)
dim m_l2power(30)
m_lonbits(0) = clng(1)
m_lonbits(1) = clng(3)
m_lonbits(2) = clng(7)
m_lonbits(3) = clng(15)
m_lonbits(4) = clng(31)
m_lonbits(5) = clng(63)
m_lonbits(6) = clng(127)
m_lonbits(7) = clng(255)
m_lonbits(8) = clng(511)
m_lonbits(9) = clng(1023)
m_lonbits(10) = clng(2047)
m_lonbits(11) = clng(4095)
m_lonbits(12) = clng(8191)
m_lonbits(13) = clng(16383)
m_lonbits(14) = clng(32767)
m_lonbits(15) = clng(65535)
m_lonbits(16) = clng(131071)
m_lonbits(17) = clng(262143)
m_lonbits(18) = clng(524287)
m_lonbits(19) = clng(1048575)
m_lonbits(20) = clng(2097151)
m_lonbits(21) = clng(4194303)
m_lonbits(22) = clng(8388607)
m_lonbits(23) = clng(16777215)
m_lonbits(24) = clng(33554431)
m_lonbits(25) = clng(67108863)
m_lonbits(26) = clng(134217727)
m_lonbits(27) = clng(268435455)
m_lonbits(28) = clng(536870911)
m_lonbits(29) = clng(1073741823)
m_lonbits(30) = clng(2147483647)
m_l2power(0) = clng(1)
m_l2power(1) = clng(2)
m_l2power(2) = clng(4)
m_l2power(3) = clng(8)
m_l2power(4) = clng(16)
m_l2power(5) = clng(32)
m_l2power(6) = clng(64)
m_l2power(7) = clng(128)
m_l2power(8) = clng(256)
m_l2power(9) = clng(512)
m_l2power(10) = clng(1024)
m_l2power(11) = clng(2048)
m_l2power(12) = clng(4096)
m_l2power(13) = clng(8192)
m_l2power(14) = clng(16384)
m_l2power(15) = clng(32768)
m_l2power(16) = clng(65536)
m_l2power(17) = clng(131072)
m_l2power(18) = clng(262144)
m_l2power(19) = clng(524288)
m_l2power(20) = clng(1048576)
m_l2power(21) = clng(2097152)
m_l2power(22) = clng(4194304)
m_l2power(23) = clng(8388608)
m_l2power(24) = clng(16777216)
m_l2power(25) = clng(33554432)
m_l2power(26) = clng(67108864)
m_l2power(27) = clng(134217728)
m_l2power(28) = clng(268435456)
m_l2power(29) = clng(536870912)
m_l2power(30) = clng(1073741824)
'
' the main hmac function
'
function hmac(text,key)
dim hkey
dim ipad(63)
dim opad(63)
dim odata(79)
dim idata()
redim idata(64 + len(text) - 1)
if len(key)>64 then
hkey = calcmd5(key)
else
hkey = key
end if
dim x
for x=0 to 63
idata(x) = &h36
odata(x) = &h5c
ipad(x) = &h36
opad(x) = &h5c
next
for x=0 to len(hkey)-1
ipad(x) = ipad(x) xor asc(cstr(mid(hkey,x+1,1)))
opad(x) = opad(x) xor asc(cstr(mid(hkey,x+1,1)))
idata(x) = ipad(x) and &hff
odata(x) = opad(x) and &hff
next
for x=0 to len(text)-1
idata(64+x) = asc(cstr(mid(text,x+1,1))) and &hff
next
dim innerhashout
innerhashout = binl2byt(b_calcmd5(idata))
for x=0 to 15
odata(64+x) = innerhashout(x)
next
hmac = binl2hex(b_calcmd5(odata))
end function
'
' the main md5 function
'
function md5(smessage)
dim x, r
x = converttowordarray(smessage)
r = coremd5(x)
md5 = lcase(r(0) + r(1) + r(2) + r(3))
end function
'
' main auxilliary functions
'
function calcmd5(str)
calcmd5 = binl2hex(coremd5(str2binl(str)))
end function
function b_calcmd5(barray)
b_calcmd5 = coremd5(bytarray2binl(barray))
end function
function coremd5(x)
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x)-1 step 16
aa = a
bb = b
cc = c
dd = d
md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
md5_ff c, d, a, b, x(k + 2), s13, &h242070db
md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
md5_gg d, a, b, c, x(k + 10), s22, &h2441453
md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = addunsigned(a, aa)
b = addunsigned(b, bb)
c = addunsigned(c, cc)
d = addunsigned(d, dd)
next
coremd5 = array(a,b,c,d)
end function
'
' screwball md5 functions
'
sub md5_ff(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_f(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
sub md5_gg(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_g(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
sub md5_hh(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_h(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
sub md5_ii(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_i(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
function md5_f(x, y, z)
md5_f = (x and y) or ((not x) and z)
end function
function md5_g(x, y, z)
md5_g = (x and z) or (y and (not z))
end function
function md5_h(x, y, z)
md5_h = (x xor y xor z)
end function
function md5_i(x, y, z)
md5_i = (y xor (x or (not z)))
end function
'
' utility functions
'
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
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
function rotateleft(lvalue, ishiftbits)
rotateleft = lshift(lvalue, ishiftbits) or rshift(lvalue, (32 - ishiftbits))
end function
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
lresult = lresult xor lx8 xor ly8
end if
addunsigned = lresult
end function
function converttowordarray(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
function wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = rshift(lvalue, lcount * bits_to_a_byte) and m_lonbits(bits_to_a_byte - 1)
wordtohex = wordtohex & right("0" & hex(lbyte), 2)
next
end function
function str2binl(str)
dim nblk
nblk = ( rshift((len(str) + 8), 6) ) + 1 ' number of 16-word blocks
dim blks()
redim blks(nblk*16 - 1)
dim x
for x=0 to nblk * 16 - 1
blks(x) = 0
next
dim aridx
for x = 0 to len(str)-1
aridx = rshift(x,2)
blks(aridx) = blks(aridx) or lshift(asc(cstr(mid(str,x+1,1))) and &hff, ((x mod 4) * 8))
next
blks(rshift(x,2)) = blks(rshift(x,2)) or lshift(&h80, ((x mod 4) * 8))
blks(nblk*16-2) = len(str) * 8
str2binl = blks
end function
function bytarray2binl(barray)
dim nblk
nblk = rshift((ubound(barray) + 8), 6) + 1 ' number of 16-word blocks
dim blks()
redim blks(nblk*16 - 1)
dim x
for x = 0 to nblk*16 - 1
blks(x) = 0
next
dim aridx
for x = 0 to ubound(barray)
aridx = rshift(x,2)
blks(aridx) = blks(aridx) or lshift( barray(x) and &hff, (x mod 4) * 8)
next
blks(rshift(x,2)) = blks(rshift(x,2)) or lshift(&h80, ((x mod 4) * 8))
blks(nblk*16-2) = (ubound(barray)+1) * 8
bytarray2binl = blks
end function
function binl2byt(binarray)
dim bytarray()
redim bytarray(((ubound(binarray)+1) * 4) - 1)
dim str
str = ""
dim x
for x = 0 to ((ubound(binarray)+1) * 4) -1
bytarray(x) = _
lshift(( rshift( binarray(rshift(x,2)), ((x mod 4)*8+4) ) and &hf ), 4) _
or _
(rshift(binarray(rshift(x,2)),((x mod 4)*8))) and &hf
next
binl2byt = bytarray
end function
function binl2hex(binarray)
dim hex_tab
hex_tab = "0123456789abcdef"
dim str
str = ""
dim x
for x=0 to ((ubound(binarray)+1) * 4) - 1
str = str + mid(hex_tab,( rshift(binarray(rshift(x,2)), ((x mod 4)*8+4)) and &hf )+1, 1) + _
mid(hex_tab,( rshift(binarray(rshift(x,2)), ((x mod 4)*8)) and &hf )+1, 1)
next
binl2hex = str
end function
%>
2.send.asp
<!-- #include file="hmac-md5.asp" -->
<%
dim merchantid
dim keyvalue
merchantid = request("cid") '''商户编号
keyvalue = request("mykey") '''商户密钥
orderid = request("orderid") '''订单编号
amount = request("totalmoney") '''订单金额
%>
<%
dim merchantcallbackurl
'设定秘钥,其中正式的merchantid以及秘钥value 需要从yeepay易宝提供给商家的商家自助服务系统获得
merchantid = merchantid '测试使用 merchant id = "1001001"
keyvalue = keyvalue '测试使用 keyvalue = "key"
merchantcallbackurl = "" '用户完成交易完成后, 控制应用返回到商家自己的url
%>
<!-- #include file="yeepaycommon.asp" -->
<%
dim orderid
dim productdesc
dim productcat
dim productid
dim cur
dim smctproperties
dim snewstring
dim frpid
'商家设置用户购买商品的支付信息
orderid=orderid '商家的交易定单号此参数可选,但不能有重复(如果不输入yeepay会自动帮助商家生成一个订单号)
productid = "0" '商品id(尽量清楚填写,方便以后统计订单)
amount=amount '购买金额(必须)
cur="cny" '货币单位(固定不需要修改,现在一般只会支持人民币交易)
productdesc = "" '商品描述(可保持为空)
productcat = "" '商品种类(可保持为空)
'商家可以把一些辅助信息放在mp列表中,当从yeepay易宝平台返回时,还可以原样取出商家设定的一些信息。可以提供商家临时保存信息的功能
smctproperties = "" '(可保持为空)
'如果直接到yeepay网关设定为空即可,而在商家端选择银行的情况下请参见银行列表
frpid="" '(可选)
'调用签名函数生成签名串
snewstring = getreqhmacstring(orderid,amount,cur,productid,productcat,productdesc,merchantcallbackurl,smctproperties,frpid)
%>
<html>
<head>
<title>易宝支付</title>
</head>
<body onload="document.yeepay.submit()">
<form name="yeepay" action="<%=nodeauthorizationurl%>" method="post">
<input type="hidden" name="p0_cmd" value="<%=messagetype%>">
<input type="hidden" name="p1_merid" value="<%=merchantid%>">
<input type="hidden" name="p2_order" value="<%=orderid%>">
<input type="hidden" name="p3_amt" value="<%=amount%>">
<input type="hidden" name="p4_cur" value="<%=cur%>">
<input type="hidden" name="p5_pid" value="<%=productid%>">
<input type="hidden" name="p6_pcat" value="<%=productcat%>">
<input type="hidden" name="p7_pdesc" value="<%=productdesc%>">
<input type="hidden" name="p8_url" value="<%=merchantcallbackurl%>">
<input type="hidden" name="p9_saf" value="<%=addressflag%>">
<input type="hidden" name="pa_mp" value="<%=smctproperties%>">
<input type="hidden" name="pd_frpid" value="<%=frpid%>">
<input type="hidden" name="hmac" value="<%=snewstring%>">
</form>
</body>
</html>
3.yeepaycommon.asp
<%
dim mctsdk
dim nodeauthorizationurl
dim messagetype
dim addressflag
nodeauthorizationurl = "https://www.yeepay.com/app-merchant-proxy/node" '扣款请求url 无需更改
messagetype="buy" '消息类型
addressflag="0" '需要填写送货信息 0:不需要 1:需要
function getreqhmacstring(orderid,amount,cur,productid,productcat,productdesc,merchantcallbackurl,smctproperties,frpid)
dim sbold
'进行加密串处理,一定按照下列顺序进行
sbold=""
sbold = sbold + messagetype
sbold = sbold + merchantid
sbold = sbold + orderid
sbold = sbold + cstr(amount)
sbold = sbold + cur
sbold = sbold + productid
sbold = sbold + productcat
sbold = sbold + productdesc
sbold = sbold + merchantcallbackurl
sbold = sbold + addressflag
sbold = sbold + smctproperties
sbold = sbold + frpid
getreqhmacstring = hmac(sbold,keyvalue)
end function
function getcallbackhmacstring(scmd,serrorcode,strxid,orderid,amount,productid,userid,mp,btype)
dim sbold
'取得加密前的字符串
sbold = ""
sbold = sbold + cstr(merchantid)
sbold = sbold + scmd
sbold = sbold + serrorcode
sbold = sbold + strxid
sbold = sbold + amount
sbold = sbold + cur
sbold = sbold + productid
sbold = sbold + orderid
sbold = sbold + userid
sbold = sbold + mp
sbold = sbold + btype
getcallbackhmacstring = hmac(sbold,keyvalue)
end function
function checkhmac(scmd,serrorcode,strxid,orderid,amount,productid,userid,mp,btype,hmac)
if(hmac=getcallbackhmacstring(scmd,serrorcode,strxid,orderid,amount,productid,userid,mp,btype)) then
checkhmac = true
else
checkhmac = flase
end if
end function
'取得返回串中的所有参数
sub getcallbackvalue(byref scmd,byref serrorcode,byref strxid,byref amount,byref cur,byref productid,byref orderid,byref userid,byref mp,byref btype,byref svrhmac)
scmd = request.querystring("r0_cmd")
serrorcode = request.querystring("r1_code")
strxid = request.querystring("r2_trxid")
amount = request.querystring("r3_amt")
cur = request.querystring("r4_cur")
productid = request.querystring("r5_pid")
orderid = request.querystring("r6_order")
userid = request.querystring("r7_uid")
mp = request.querystring("r8_mp")
btype = request.querystring("r9_btype")
svrhmac = request.querystring("hmac")
end sub
%>
1.md5.asp
复制代码 代码如下:
<%
'''''''''
' @description: 快钱网关接口范例
' @copyright (c) 上海快钱信息服务有限公司
' @version 2.0
'''''''''
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
lresult = lresult xor lx8 xor ly8
end if
addunsigned = lresult
end function
private function md5_f(x, y, z)
md5_f = (x and y) or ((not x) and z)
end function
private function md5_g(x, y, z)
md5_g = (x and z) or (y and (not z))
end function
private function md5_h(x, y, z)
md5_h = (x xor y xor z)
end function
private function md5_i(x, y, z)
md5_i = (y xor (x or (not z)))
end function
private sub md5_ff(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_f(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_gg(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_g(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_hh(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_h(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_ii(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_i(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private function converttowordarray(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 wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = rshift(lvalue, lcount * bits_to_a_byte) and m_lonbits(bits_to_a_byte - 1)
wordtohex = wordtohex & right("0" & hex(lbyte), 2)
next
end function
public function md5(smessage)
m_lonbits(0) = clng(1)
m_lonbits(1) = clng(3)
m_lonbits(2) = clng(7)
m_lonbits(3) = clng(15)
m_lonbits(4) = clng(31)
m_lonbits(5) = clng(63)
m_lonbits(6) = clng(127)
m_lonbits(7) = clng(255)
m_lonbits(8) = clng(511)
m_lonbits(9) = clng(1023)
m_lonbits(10) = clng(2047)
m_lonbits(11) = clng(4095)
m_lonbits(12) = clng(8191)
m_lonbits(13) = clng(16383)
m_lonbits(14) = clng(32767)
m_lonbits(15) = clng(65535)
m_lonbits(16) = clng(131071)
m_lonbits(17) = clng(262143)
m_lonbits(18) = clng(524287)
m_lonbits(19) = clng(1048575)
m_lonbits(20) = clng(2097151)
m_lonbits(21) = clng(4194303)
m_lonbits(22) = clng(8388607)
m_lonbits(23) = clng(16777215)
m_lonbits(24) = clng(33554431)
m_lonbits(25) = clng(67108863)
m_lonbits(26) = clng(134217727)
m_lonbits(27) = clng(268435455)
m_lonbits(28) = clng(536870911)
m_lonbits(29) = clng(1073741823)
m_lonbits(30) = clng(2147483647)
m_l2power(0) = clng(1)
m_l2power(1) = clng(2)
m_l2power(2) = clng(4)
m_l2power(3) = clng(8)
m_l2power(4) = clng(16)
m_l2power(5) = clng(32)
m_l2power(6) = clng(64)
m_l2power(7) = clng(128)
m_l2power(8) = clng(256)
m_l2power(9) = clng(512)
m_l2power(10) = clng(1024)
m_l2power(11) = clng(2048)
m_l2power(12) = clng(4096)
m_l2power(13) = clng(8192)
m_l2power(14) = clng(16384)
m_l2power(15) = clng(32768)
m_l2power(16) = clng(65536)
m_l2power(17) = clng(131072)
m_l2power(18) = clng(262144)
m_l2power(19) = clng(524288)
m_l2power(20) = clng(1048576)
m_l2power(21) = clng(2097152)
m_l2power(22) = clng(4194304)
m_l2power(23) = clng(8388608)
m_l2power(24) = clng(16777216)
m_l2power(25) = clng(33554432)
m_l2power(26) = clng(67108864)
m_l2power(27) = clng(134217728)
m_l2power(28) = clng(268435456)
m_l2power(29) = clng(536870912)
m_l2power(30) = clng(1073741824)
dim x
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
x = converttowordarray(smessage)
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x) step 16
aa = a
bb = b
cc = c
dd = d
md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
md5_ff c, d, a, b, x(k + 2), s13, &h242070db
md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
md5_gg d, a, b, c, x(k + 10), s22, &h2441453
md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = addunsigned(a, aa)
b = addunsigned(b, bb)
c = addunsigned(c, cc)
d = addunsigned(d, dd)
next
md5 = lcase(wordtohex(a) & wordtohex(b) & wordtohex(c) & wordtohex(d)) '32byte
'md5 = lcase(wordtohex(b) & wordtohex(c)) 'i crop this to fit 16byte database password :d
end function
%>
2.send.asp
复制代码 代码如下:
<!--#include file="md5.asp"-->
<%
'''''''''
' @description: 快钱网关接口范例
' @copyright (c) 上海快钱信息服务有限公司
' @version 2.0
'''''''''
merchant_id = request("cid") '''商户编号
merchant_key = request("mykey") '''商户密钥
orderid = request("orderid") '''订单编号
amount = request("totalmoney") '''订单金额
curr = "1" '''货币类型,1为人民币
issupportdes = "2" '''是否安全校验,2为必校验,推荐
merchant_url = "" '''支付结果返回地址
pname = request("pname") '''支付人姓名
commodity_info = "" '''商品信息
merchant_param = "" '''商户私有参数
pemail="" '''传递email到快钱网关页面
pid="" '''代理/合作伙伴商户编号
'''生成加密串,注意顺序
scrtstr="merchant_id=" & merchant_id & "&orderid=" & orderid & "&amount=" & amount & "&merchant_url=" & merchant_url & "&merchant_key=" & merchant_key
mac=ucase(md5(scrtstr))
%>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
<head>
<title>快钱99bill</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" >
</head>
<body onload="javascript:document.frm.submit()">
<form name="frm" method="post" action="https://www.99bill.com/webapp/receivemerchantinfoaction.do">
<input name="merchant_id" type="hidden" value="<%=merchant_id%>">
<input name="orderid" type="hidden" value="<%=orderid%>">
<input name="amount" type="hidden" value="<%=amount%>">
<input name="currency" type="hidden" value="<%=curr%>">
<input name="issupportdes" type="hidden" value="<%=issupportdes%>">
<input name="mac" type="hidden" value="<%=mac%>">
<input name="merchant_url" type="hidden" value="<%=merchant_url%>">
<input name="pname" type="hidden" value="<%=pname%>">
<input name="commodity_info" type="hidden" value="<%=commodity_info%>">
<input name="merchant_param" type="hidden" value="<%=merchant_param%>">
<input name="pemail" type="hidden" value="<%=pemail%>">
<input name="pid" type="hidden" value="<%=pid%>">
</form>
</body>
</html>
alipay
1.alipay_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 str2bin(varstr)
dim varasc
dim i
dim varchar
dim varlow
dim varhigh
str2bin=""
for i=1 to len(varstr)
varchar=mid(varstr,i,1)
varasc = asc(varchar)
if varasc<0 then
varasc = varasc + 65535
end if
if varasc>255 then
varlow = left(hex(asc(varchar)),2)
varhigh = right(hex(asc(varchar)),2)
str2bin = str2bin & chrb("&h" & varlow) & chrb("&h" & varhigh)
else
str2bin = str2bin & chrb(ascb(varchar))
end if
next
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
lresult = lresult xor lx8 xor ly8
end if
addunsigned = lresult
end function
private function md5_f(x, y, z)
md5_f = (x and y) or ((not x) and z)
end function
private function md5_g(x, y, z)
md5_g = (x and z) or (y and (not z))
end function
private function md5_h(x, y, z)
md5_h = (x xor y xor z)
end function
private function md5_i(x, y, z)
md5_i = (y xor (x or (not z)))
end function
private sub md5_ff(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_f(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_gg(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_g(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_hh(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_h(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_ii(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_i(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private function converttowordarray(smessage)
dim lmessagelength
dim lnumberofwords
dim lwordarray()
dim lbyteposition
dim lbytecount
dim lwordcount
const modulus_bits = 512
const congruent_bits = 448
lmessagelength = lenb(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(ascb(midb(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 wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = rshift(lvalue, lcount * bits_to_a_byte) and m_lonbits(bits_to_a_byte - 1)
wordtohex = wordtohex & right("0" & hex(lbyte), 2)
next
end function
public function md5(smessage)
m_lonbits(0) = clng(1)
m_lonbits(1) = clng(3)
m_lonbits(2) = clng(7)
m_lonbits(3) = clng(15)
m_lonbits(4) = clng(31)
m_lonbits(5) = clng(63)
m_lonbits(6) = clng(127)
m_lonbits(7) = clng(255)
m_lonbits(8) = clng(511)
m_lonbits(9) = clng(1023)
m_lonbits(10) = clng(2047)
m_lonbits(11) = clng(4095)
m_lonbits(12) = clng(8191)
m_lonbits(13) = clng(16383)
m_lonbits(14) = clng(32767)
m_lonbits(15) = clng(65535)
m_lonbits(16) = clng(131071)
m_lonbits(17) = clng(262143)
m_lonbits(18) = clng(524287)
m_lonbits(19) = clng(1048575)
m_lonbits(20) = clng(2097151)
m_lonbits(21) = clng(4194303)
m_lonbits(22) = clng(8388607)
m_lonbits(23) = clng(16777215)
m_lonbits(24) = clng(33554431)
m_lonbits(25) = clng(67108863)
m_lonbits(26) = clng(134217727)
m_lonbits(27) = clng(268435455)
m_lonbits(28) = clng(536870911)
m_lonbits(29) = clng(1073741823)
m_lonbits(30) = clng(2147483647)
m_l2power(0) = clng(1)
m_l2power(1) = clng(2)
m_l2power(2) = clng(4)
m_l2power(3) = clng(8)
m_l2power(4) = clng(16)
m_l2power(5) = clng(32)
m_l2power(6) = clng(64)
m_l2power(7) = clng(128)
m_l2power(8) = clng(256)
m_l2power(9) = clng(512)
m_l2power(10) = clng(1024)
m_l2power(11) = clng(2048)
m_l2power(12) = clng(4096)
m_l2power(13) = clng(8192)
m_l2power(14) = clng(16384)
m_l2power(15) = clng(32768)
m_l2power(16) = clng(65536)
m_l2power(17) = clng(131072)
m_l2power(18) = clng(262144)
m_l2power(19) = clng(524288)
m_l2power(20) = clng(1048576)
m_l2power(21) = clng(2097152)
m_l2power(22) = clng(4194304)
m_l2power(23) = clng(8388608)
m_l2power(24) = clng(16777216)
m_l2power(25) = clng(33554432)
m_l2power(26) = clng(67108864)
m_l2power(27) = clng(134217728)
m_l2power(28) = clng(268435456)
m_l2power(29) = clng(536870912)
m_l2power(30) = clng(1073741824)
dim x
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
x = converttowordarray(str2bin(smessage))
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x) step 16
aa = a
bb = b
cc = c
dd = d
md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
md5_ff c, d, a, b, x(k + 2), s13, &h242070db
md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
md5_gg d, a, b, c, x(k + 10), s22, &h2441453
md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = addunsigned(a, aa)
b = addunsigned(b, bb)
c = addunsigned(c, cc)
d = addunsigned(d, dd)
next
md5 = lcase(wordtohex(a) & wordtohex(b) & wordtohex(c) & wordtohex(d))
end function
%>
2.alipay_payto.asp
复制代码 代码如下:
<!--#include file="alipay_md5.asp"-->
<%
class creatalipayitemurl
'获得最终的购买url
public function creatalipayitemurl(t1,t4,t5,service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url,key)
dim itemurl
dim interface_url,imgsrc,imgtitle
'初始化各必要变量
interface_url = t1 '支付接口
imgsrc = t4 '支付宝按钮图片
imgtitle = t5 '按钮悬停说明
'add by sunzhizhi 2006-5-10
mystr = array("service="&service,"agent="&agent,"partner="&partner,"subject="&subject,"body="&body,"out_trade_no="&out_trade_no,"price="&price,"discount="&discount,"show_url="&show_url,"quantity="&quantity,"payment_type="&payment_type,"logistics_type="&logistics_type,"logistics_fee="&logistics_fee,"logistics_payment="&logistics_payment,"logistics_type_1="&logistics_type_1,"logistics_fee_1="&logistics_fee_1,"logistics_payment_1="&logistics_payment_1,"seller_email="&seller_email,"notify_url="¬ify_url,"return_url="&return_url)
count=ubound(mystr)
for i = count to 0 step -1
minmax = mystr( 0 )
minmaxslot = 0
for j = 1 to i
mark = (mystr( j ) > minmax)
if mark then
minmax = mystr( j )
minmaxslot = j
end if
next
if minmaxslot <> i then
temp = mystr( minmaxslot )
mystr( minmaxslot ) = mystr( i )
mystr( i ) = temp
end if
next
for j = 0 to count step 1
value = split(mystr( j ), "=")
if value(1)<>"" then
if j=count then
md5str= md5str&mystr( j )
else
md5str= md5str&mystr( j )&"&"
end if
end if
next
md5str=md5str&key
' response.write md5str
sign=md5(md5str)
itemurl = itemurl&interface_url
for j = 0 to count step 1
value = split(mystr( j ), "=")
if value(1)<>"" then
itemurl= itemurl&mystr( j )&"&"
end if
next
itemurl = itemurl&"sign="&sign&"&sign_type="&sign_type
'response.write itemurl
creatalipayitemurl = itemurl
end function
public function get_alipaybuttonurl(itemurl,imgtitle,imgsrc)
dim responsetext1
responsetext1 = responsetext1 & "<a href="" & itemurl & "" href="" & itemurl & "" target='_blank'>" '购买网址
responsetext1 = responsetext1 & "<img alt='" & imgtitle & "' src="" " src="" "图片说明
responsetext1 = responsetext1 & imgsrc '图片地址
responsetext1 = responsetext1 & "' align='absmiddle' border='0'/></a>"
get_alipaybuttonurl=responsetext1
end function
end class
%>
3.send1.asp
复制代码 代码如下:
<!--#include file="alipay_payto.asp"-->
<%
cid = request("cid") '''商户编号
response.write cid&"<br>"
meykey = request("mykey") '''商户密钥
response.write meykey&"<br>"
out_trade_no = request("orderid") '''订单编号
response.write out_trade_no&"<br>"
totalmoeny = request("totalmoney") '''订单金额
response.write totalmoeny&"<br>"
partnerid=request("other1")
response.write partnerid&"<br>"
'response.end
dim service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url
dim t1,t4,t5,key
dim alipayobj,itemurl
t1 = "https://www.alipay.com/cooperate/gateway.do?" '支付接口
t4 = "images/alipay_bwrx.gif" '支付宝按钮图片
t5 = "推荐使用支付宝付款" '按钮悬停说明
service = "trade_create_by_buyer" '"trade_create_by_buyer"
agent = partnerid '合作厂商id
partner = partnerid 'partner合作伙伴id(必须填)
sign_type = "md5"
subject = "" '商品名称
body = "" 'body 商品描述
out_trade_no = trim(replace(out_trade_no,":","")) '客户网站订单号,(现取系统时间,可改成网站自己的变量)
price = totalmoeny 'price商品单价 0.01~50000.00
discount = "0" '商品折扣
show_url = "" '商品展示地址(可以直接写网站首页网址)
quantity = "" '商品数量
payment_type = "1" '支付类型,(1代表商品购买)
logistics_type = "" '物流种类(快递)
logistics_fee = "" '物流费用
logistics_payment = "" '物流费用承担(卖家付)
logistics_type_1 = ""
logistics_fee_1 = ""
logistics_payment_1 = "" '物流费用承担(买家付)
seller_email = cid '(必须填)
key = mykey '(必须填)
notify_url= "" '服务器通知url(不使用,请不要注释或者删除此参数,不用传递给支付宝系统,alipay_notify.asp文件所在路经)
return_url= "" '服务器通知url(不使用,请不要注释或者删除此参数,不用传递给支付宝系统,alipay_notify.asp文件所在路经)
set alipayobj = new creatalipayitemurl
itemurl=alipayobj.creatalipayitemurl(t1,t4,t5,service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url,key)
response.redirect itemurl
response.end
%>
4.send.asp
复制代码 代码如下:
<!--#include file="alipay_payto.asp"-->
<%
cid = request("cid") '''商户编号
response.write cid&"<br>"
meykey = request("mykey") '''商户密钥
response.write meykey&"<br>"
orderid = request("orderid") '''订单编号
response.write orderid &"<br>"
totalmoeny = request("totalmoney") '''订单金额
response.write totalmoeny&"<br>"
partnerid=request("other1")
response.write partnerid&"<br>"
other2=request("other2")
other3=request("other3")
'response.end
dim service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url
dim t1,t4,t5,key
dim alipayobj,itemurl
t1 = "https://www.alipay.com/cooperate/gateway.do?" '支付接口
t4 = "images/alipay_bwrx.gif" '支付宝按钮图片
t5 = "推荐使用支付宝付款" '按钮悬停说明
service = "trade_create_by_buyer"
agent = partnerid '合作厂商id
partner = partnerid 'partner合作伙伴id(必须填)
sign_type = "md5"
subject = "商品" '商品名称
body = "" 'body 商品描述
out_trade_no = orderid '客户网站订单号,(现取系统时间,可改成网站自己的变量)
price = totalmoeny 'price商品单价 0.01~50000.00
discount = "0" '商品折扣
show_url = "" '商品展示地址(可以直接写网站首页网址)
quantity = "1" '商品数量
payment_type = "1" '支付类型,(1代表商品购买)
logistics_type = "express" '物流种类(快递)
logistics_fee = other3 '物流费用
logistics_payment = other2 '物流费用承担(卖家付)
logistics_type_1 = ""
logistics_fee_1 = ""
logistics_payment_1 = "" '物流费用承担(买家付)
seller_email = cid '(必须填)
key = meykey '(必须填)
notify_url= "" '服务器通知url(不使用,请不要注释或者删除此参数,不用传递给支付宝系统,alipay_notify.asp文件所在路经)
return_url= "" '服务器通知url(不使用,请不要注释或者删除此参数,不用传递给支付宝系统,alipay_notify.asp文件所在路经)
set alipayobj = new creatalipayitemurl
itemurl=alipayobj.creatalipayitemurl(t1,t4,t5,service,agent,partner,sign_type,subject,body,out_trade_no,price,discount,show_url,quantity,payment_type,logistics_type,logistics_fee,logistics_payment,logistics_type_1,logistics_fee_1,logistics_payment_1,seller_email,notify_url,return_url,key)
response.redirect itemurl
response.end
%>
chinabank
1.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
lresult = lresult xor lx8 xor ly8
end if
addunsigned = lresult
end function
private function md5_f(x, y, z)
md5_f = (x and y) or ((not x) and z)
end function
private function md5_g(x, y, z)
md5_g = (x and z) or (y and (not z))
end function
private function md5_h(x, y, z)
md5_h = (x xor y xor z)
end function
private function md5_i(x, y, z)
md5_i = (y xor (x or (not z)))
end function
private sub md5_ff(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_f(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_gg(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_g(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_hh(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_h(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private sub md5_ii(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_i(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
private function converttowordarray(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 wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = rshift(lvalue, lcount * bits_to_a_byte) and m_lonbits(bits_to_a_byte - 1)
wordtohex = wordtohex & right("0" & hex(lbyte), 2)
next
end function
public function md5(smessage)
m_lonbits(0) = clng(1)
m_lonbits(1) = clng(3)
m_lonbits(2) = clng(7)
m_lonbits(3) = clng(15)
m_lonbits(4) = clng(31)
m_lonbits(5) = clng(63)
m_lonbits(6) = clng(127)
m_lonbits(7) = clng(255)
m_lonbits(8) = clng(511)
m_lonbits(9) = clng(1023)
m_lonbits(10) = clng(2047)
m_lonbits(11) = clng(4095)
m_lonbits(12) = clng(8191)
m_lonbits(13) = clng(16383)
m_lonbits(14) = clng(32767)
m_lonbits(15) = clng(65535)
m_lonbits(16) = clng(131071)
m_lonbits(17) = clng(262143)
m_lonbits(18) = clng(524287)
m_lonbits(19) = clng(1048575)
m_lonbits(20) = clng(2097151)
m_lonbits(21) = clng(4194303)
m_lonbits(22) = clng(8388607)
m_lonbits(23) = clng(16777215)
m_lonbits(24) = clng(33554431)
m_lonbits(25) = clng(67108863)
m_lonbits(26) = clng(134217727)
m_lonbits(27) = clng(268435455)
m_lonbits(28) = clng(536870911)
m_lonbits(29) = clng(1073741823)
m_lonbits(30) = clng(2147483647)
m_l2power(0) = clng(1)
m_l2power(1) = clng(2)
m_l2power(2) = clng(4)
m_l2power(3) = clng(8)
m_l2power(4) = clng(16)
m_l2power(5) = clng(32)
m_l2power(6) = clng(64)
m_l2power(7) = clng(128)
m_l2power(8) = clng(256)
m_l2power(9) = clng(512)
m_l2power(10) = clng(1024)
m_l2power(11) = clng(2048)
m_l2power(12) = clng(4096)
m_l2power(13) = clng(8192)
m_l2power(14) = clng(16384)
m_l2power(15) = clng(32768)
m_l2power(16) = clng(65536)
m_l2power(17) = clng(131072)
m_l2power(18) = clng(262144)
m_l2power(19) = clng(524288)
m_l2power(20) = clng(1048576)
m_l2power(21) = clng(2097152)
m_l2power(22) = clng(4194304)
m_l2power(23) = clng(8388608)
m_l2power(24) = clng(16777216)
m_l2power(25) = clng(33554432)
m_l2power(26) = clng(67108864)
m_l2power(27) = clng(134217728)
m_l2power(28) = clng(268435456)
m_l2power(29) = clng(536870912)
m_l2power(30) = clng(1073741824)
dim x
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
x = converttowordarray(smessage)
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x) step 16
aa = a
bb = b
cc = c
dd = d
md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
md5_ff c, d, a, b, x(k + 2), s13, &h242070db
md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
md5_gg d, a, b, c, x(k + 10), s22, &h2441453
md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = addunsigned(a, aa)
b = addunsigned(b, bb)
c = addunsigned(c, cc)
d = addunsigned(d, dd)
next
md5 = lcase(wordtohex(a) & wordtohex(b) & wordtohex(c) & wordtohex(d)) '32byte
'md5 = lcase(wordtohex(b) & wordtohex(c)) 'i crop this to fit 16byte database password :d
end function
%>
2.send.asp
复制代码 代码如下:
<!--
* ====================================================================
*
* send.asp 由网银在线技术支持提供
*
* 本页面接收来自上页所有订单信息,并提交支付订单到网线在线支付平台....
*
*
* ====================================================================
-->
<!--#include file="md5.asp"-->
<%
'****************************************
v_mid = request("cid") ' 商户号,这里为测试商户号20000400,替换为自己的商户号即可
v_url = "" ' 商户自定义返回接收支付结果的页面 receive.asp 为接收页面
' md5密钥要跟订单提交页相同,如send.asp里的 key = "test" ,修改""号内 test 为您的密钥
key = request("mykey") ' 如果您还没有设置md5密钥请登陆我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/
' 登陆后在上面的导航栏里可能找到“资料管理”,在资料管理的二级导航栏里有“md5密钥设置”
' 建议您设置一个16位以上的密钥或更高,密钥最多64位,但设置16位已经足够了
'****************************************%>
<%
if request("orderid")<>"" then '判断是否有传递订单号
v_oid = request("orderid")
else
curdate = now() ' 根据系统时间产生订单,格式:yyyymmdd-v_mid-hmmss
ymd = year(curdate)&month(curdate)&day(curdate) ' 年月日
hms = hour(curdate)&minute(curdate)&second(curdate) ' 分秒时
v_oid = ymd&"-"&v_mid&"-"&hms ' 推荐订单号构成格式为 年月日-商户号-小时分钟秒
end if
v_amount = request("totalmoney") ' 订单金额
v_moneytype = "cny" ' 币种
text = v_amount&v_moneytype&v_oid&v_mid&v_url&key ' 拼凑加密串
v_md5info=ucase(trim(md5(text))) ' 网银支付平台对md5值只认大写字符串,所以小写的md5值得转换为大写
'**********以下几项为可选信息,如果发送网银在线会保存此信息,使用和不使用都不影响支付!**************
v_rcvname = request("v_rcvname") ' 收货人
v_rcvaddr = request("v_rcvaddr") ' 收货地址
v_rcvtel = request("v_rcvtel") ' 收货人电话
v_rcvpost = request("v_rcvpost") ' 收货人邮编
v_rcvemail = request("v_rcvemail") ' 收货人邮件
v_rcvmobile = request("v_rcvmobile") ' 收货人手机号
v_ordername = request("v_ordername") ' 订货人姓名
v_orderaddr = request("v_orderaddr") ' 订货人地址
v_ordertel = request("v_ordertel") ' 订货人电话
v_orderpost = request("v_orderpost") ' 订货人邮编
v_orderemail = request("v_orderemail") ' 订货人邮件
v_ordermobile = request("v_ordermobile") ' 订货人手机号
remark1 = request("remark1") ' 备注字段1
remark2 = request("remark2") ' 备注字段2
%>
<!--以下信息为标准的 html 格式 + asp 语言 拼凑而成的 网银在线 支付接口标准演示页面 -->
<html>
<body onload="javascript:document.e_form.submit()">
<form action="https://pay3.chinabank.com.cn/paygate" method="post" name="e_form">
<!--以下几项为网上支付重要信息,信息必须正确无误,信息会影响支付进行!-->
<input type="hidden" name="v_md5info" value="<%=v_md5info%>" size="100">
<input type="hidden" name="v_mid" value="<%=v_mid%>">
<input type="hidden" name="v_oid" value="<%=v_oid%>">
<input type="hidden" name="v_amount" value="<%=v_amount%>">
<input type="hidden" name="v_moneytype" value="<%=v_moneytype%>">
<input type="hidden" name="v_url" value="<%=v_url%>">
<!--以下几项项为网上支付完成后,随支付反馈信息一同传给信息接收页,在传输过程中内容不会改变,如:receive.asp -->
<input type="hidden" name="remark1" value="<%=remark1%>">
<input type="hidden" name="remark2" value="<%=remark2%>">
<!--以下几项与网上支付货款无关,只是用来记录客户信息,可以不用,使用和不使用都不影响支付 -->
<input type="hidden" name="v_rcvname" value="<%=v_rcvname%>">
<input type="hidden" name="v_rcvaddr" value="<%=v_rcvaddr%>">
<input type="hidden" name="v_rcvtel" value="<%=v_rcvtel%>">
<input type="hidden" name="v_rcvpost" value="<%=v_rcvpost%>">
<input type="hidden" name="v_rcvemail" value="<%=v_rcvemail%>">
<input type="hidden" name="v_rcvmobile" value="<%=v_rcvmobile%>">
<input type="hidden" name="v_ordername" value="<%=v_ordername%>">
<input type="hidden" name="v_orderaddr" value="<%=v_orderaddr%>">
<input type="hidden" name="v_ordertel" value="<%=v_ordertel%>">
<input type="hidden" name="v_orderpost" value="<%=v_orderpost%>">
<input type="hidden" name="v_orderemail" value="<%=v_orderemail%>">
<input type="hidden" name="v_ordermobile" value="<%=v_ordermobile%>">
</form>
</body>
</html>
tenpay
1.asp_md5.asp
复制代码 代码如下:
<%
private const asp_bits_to_a_byte = 8
private const asp_bytes_to_a_word = 4
private const asp_bits_to_a_word = 32
private asp_m_lonbits(30)
private asp_m_l2power(30)
private function asp_lshift(lvalue, ishiftbits)
if ishiftbits = 0 then
asp_lshift = lvalue
exit function
elseif ishiftbits = 31 then
if lvalue and 1 then
asp_lshift = &h80000000
else
asp_lshift = 0
end if
exit function
elseif ishiftbits < 0 or ishiftbits > 31 then
err.raise 6
end if
if (lvalue and asp_m_l2power(31 - ishiftbits)) then
asp_lshift = ((lvalue and asp_m_lonbits(31 - (ishiftbits + 1))) * asp_m_l2power(ishiftbits)) or &h80000000
else
asp_lshift = ((lvalue and asp_m_lonbits(31 - ishiftbits)) * asp_m_l2power(ishiftbits))
end if
end function
private function asp_str2binold(varstr)
asp_str2binold=""
for i=1 to len(varstr)
varchar=mid(varstr,i,1)
varasc = asc(varchar)
if varasc<0 then
varasc = varasc + 65535
end if
if varasc>255 then
varlow = left(hex(asc(varchar)),2)
varhigh = right(hex(asc(varchar)),2)
asp_str2binold = asp_str2binold & chrb("&h" & varlow) & chrb("&h" & varhigh)
else
asp_str2binold = asp_str2binold & chrb(ascb(varchar))
end if
next
end function
private function asp_str2bin(varstr)
asp_str2bin=""
for i=1 to len(varstr)
varchar=mid(varstr,i,1)
code = server.urlencode(varchar)
if len(code) = 1 then
asp_str2bin = asp_str2bin & chrb(ascb(code))
else
codearr = split(code,"%")
for j=1 to ubound(codearr)
asp_str2bin = asp_str2bin & chrb("&h" & codearr(j))
next
end if
next
end function
private function asp_rshift(lvalue, ishiftbits)
if ishiftbits = 0 then
asp_rshift = lvalue
exit function
elseif ishiftbits = 31 then
if lvalue and &h80000000 then
asp_rshift = 1
else
asp_rshift = 0
end if
exit function
elseif ishiftbits < 0 or ishiftbits > 31 then
err.raise 6
end if
asp_rshift = (lvalue and &h7ffffffe) \ asp_m_l2power(ishiftbits)
if (lvalue and &h80000000) then
asp_rshift = (asp_rshift or (&h40000000 \ asp_m_l2power(ishiftbits - 1)))
end if
end function
private function asp_rotateleft(lvalue, ishiftbits)
asp_rotateleft = asp_lshift(lvalue, ishiftbits) or asp_rshift(lvalue, (32 - ishiftbits))
end function
private function asp_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
lresult = lresult xor lx8 xor ly8
end if
asp_addunsigned = lresult
end function
private function asp_md5_f(x, y, z)
asp_md5_f = (x and y) or ((not x) and z)
end function
private function asp_md5_g(x, y, z)
asp_md5_g = (x and z) or (y and (not z))
end function
private function asp_md5_h(x, y, z)
asp_md5_h = (x xor y xor z)
end function
private function asp_md5_i(x, y, z)
asp_md5_i = (y xor (x or (not z)))
end function
private sub asp_md5_ff(a, b, c, d, x, s, ac)
a = asp_addunsigned(a, asp_addunsigned(asp_addunsigned(asp_md5_f(b, c, d), x), ac))
a = asp_rotateleft(a, s)
a = asp_addunsigned(a, b)
end sub
private sub asp_md5_gg(a, b, c, d, x, s, ac)
a = asp_addunsigned(a, asp_addunsigned(asp_addunsigned(asp_md5_g(b, c, d), x), ac))
a = asp_rotateleft(a, s)
a = asp_addunsigned(a, b)
end sub
private sub asp_md5_hh(a, b, c, d, x, s, ac)
a = asp_addunsigned(a, asp_addunsigned(asp_addunsigned(asp_md5_h(b, c, d), x), ac))
a = asp_rotateleft(a, s)
a = asp_addunsigned(a, b)
end sub
private sub asp_md5_ii(a, b, c, d, x, s, ac)
a = asp_addunsigned(a, asp_addunsigned(asp_addunsigned(asp_md5_i(b, c, d), x), ac))
a = asp_rotateleft(a, s)
a = asp_addunsigned(a, b)
end sub
private function asp_converttowordarray(smessage)
dim lmessagelength
dim lnumberofwords
dim lwordarray()
dim lbyteposition
dim lbytecount
dim lwordcount
const modulus_bits = 512
const congruent_bits = 448
lmessagelength = lenb(smessage)
lnumberofwords = (((lmessagelength + ((modulus_bits - congruent_bits) \ asp_bits_to_a_byte)) \ (modulus_bits \ asp_bits_to_a_byte)) + 1) * (modulus_bits \ asp_bits_to_a_word)
redim lwordarray(lnumberofwords - 1)
lbyteposition = 0
lbytecount = 0
do until lbytecount >= lmessagelength
lwordcount = lbytecount \ asp_bytes_to_a_word
lbyteposition = (lbytecount mod asp_bytes_to_a_word) * asp_bits_to_a_byte
lwordarray(lwordcount) = lwordarray(lwordcount) or asp_lshift(ascb(midb(smessage, lbytecount + 1, 1)), lbyteposition)
lbytecount = lbytecount + 1
loop
lwordcount = lbytecount \ asp_bytes_to_a_word
lbyteposition = (lbytecount mod asp_bytes_to_a_word) * asp_bits_to_a_byte
lwordarray(lwordcount) = lwordarray(lwordcount) or asp_lshift(&h80, lbyteposition)
lwordarray(lnumberofwords - 2) = asp_lshift(lmessagelength, 3)
lwordarray(lnumberofwords - 1) = asp_rshift(lmessagelength, 29)
asp_converttowordarray = lwordarray
end function
private function asp_wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = asp_rshift(lvalue, lcount * asp_bits_to_a_byte) and asp_m_lonbits(asp_bits_to_a_byte - 1)
asp_wordtohex = asp_wordtohex & right("0" & hex(lbyte), 2)
next
end function
public function asp_md5(smessage)
asp_m_lonbits(0) = clng(1)
asp_m_lonbits(1) = clng(3)
asp_m_lonbits(2) = clng(7)
asp_m_lonbits(3) = clng(15)
asp_m_lonbits(4) = clng(31)
asp_m_lonbits(5) = clng(63)
asp_m_lonbits(6) = clng(127)
asp_m_lonbits(7) = clng(255)
asp_m_lonbits(8) = clng(511)
asp_m_lonbits(9) = clng(1023)
asp_m_lonbits(10) = clng(2047)
asp_m_lonbits(11) = clng(4095)
asp_m_lonbits(12) = clng(8191)
asp_m_lonbits(13) = clng(16383)
asp_m_lonbits(14) = clng(32767)
asp_m_lonbits(15) = clng(65535)
asp_m_lonbits(16) = clng(131071)
asp_m_lonbits(17) = clng(262143)
asp_m_lonbits(18) = clng(524287)
asp_m_lonbits(19) = clng(1048575)
asp_m_lonbits(20) = clng(2097151)
asp_m_lonbits(21) = clng(4194303)
asp_m_lonbits(22) = clng(8388607)
asp_m_lonbits(23) = clng(16777215)
asp_m_lonbits(24) = clng(33554431)
asp_m_lonbits(25) = clng(67108863)
asp_m_lonbits(26) = clng(134217727)
asp_m_lonbits(27) = clng(268435455)
asp_m_lonbits(28) = clng(536870911)
asp_m_lonbits(29) = clng(1073741823)
asp_m_lonbits(30) = clng(2147483647)
asp_m_l2power(0) = clng(1)
asp_m_l2power(1) = clng(2)
asp_m_l2power(2) = clng(4)
asp_m_l2power(3) = clng(8)
asp_m_l2power(4) = clng(16)
asp_m_l2power(5) = clng(32)
asp_m_l2power(6) = clng(64)
asp_m_l2power(7) = clng(128)
asp_m_l2power(8) = clng(256)
asp_m_l2power(9) = clng(512)
asp_m_l2power(10) = clng(1024)
asp_m_l2power(11) = clng(2048)
asp_m_l2power(12) = clng(4096)
asp_m_l2power(13) = clng(8192)
asp_m_l2power(14) = clng(16384)
asp_m_l2power(15) = clng(32768)
asp_m_l2power(16) = clng(65536)
asp_m_l2power(17) = clng(131072)
asp_m_l2power(18) = clng(262144)
asp_m_l2power(19) = clng(524288)
asp_m_l2power(20) = clng(1048576)
asp_m_l2power(21) = clng(2097152)
asp_m_l2power(22) = clng(4194304)
asp_m_l2power(23) = clng(8388608)
asp_m_l2power(24) = clng(16777216)
asp_m_l2power(25) = clng(33554432)
asp_m_l2power(26) = clng(67108864)
asp_m_l2power(27) = clng(134217728)
asp_m_l2power(28) = clng(268435456)
asp_m_l2power(29) = clng(536870912)
asp_m_l2power(30) = clng(1073741824)
dim x
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
x = asp_converttowordarray(asp_str2bin(smessage))
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x) step 16
aa = a
bb = b
cc = c
dd = d
asp_md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
asp_md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
asp_md5_ff c, d, a, b, x(k + 2), s13, &h242070db
asp_md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
asp_md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
asp_md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
asp_md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
asp_md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
asp_md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
asp_md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
asp_md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
asp_md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
asp_md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
asp_md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
asp_md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
asp_md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
asp_md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
asp_md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
asp_md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
asp_md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
asp_md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
asp_md5_gg d, a, b, c, x(k + 10), s22, &h2441453
asp_md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
asp_md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
asp_md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
asp_md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
asp_md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
asp_md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
asp_md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
asp_md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
asp_md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
asp_md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
asp_md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
asp_md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
asp_md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
asp_md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
asp_md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
asp_md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
asp_md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
asp_md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
asp_md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
asp_md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
asp_md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
asp_md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
asp_md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
asp_md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
asp_md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
asp_md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
asp_md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
asp_md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
asp_md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
asp_md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
asp_md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
asp_md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
asp_md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
asp_md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
asp_md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
asp_md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
asp_md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
asp_md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
asp_md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
asp_md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
asp_md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
asp_md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = asp_addunsigned(a, aa)
b = asp_addunsigned(b, bb)
c = asp_addunsigned(c, cc)
d = asp_addunsigned(d, dd)
next
asp_md5 = lcase(asp_wordtohex(a) & asp_wordtohex(b) & asp_wordtohex(c) & asp_wordtohex(d))
end function
'使用方法是 md5 ("字符串") 下面是使用示范
'response.write "asp_md5('a')的加密结果为[" & asp_md5 ("a") & "]<br>"
'response.write "asp_md5('b')的加密结果为[" & asp_md5 ("b") & "]"
%>
2.send.asp
复制代码 代码如下:
<!-- #include file="asp_md5.asp" -->
<%
dim merchantid
dim keyvalue
merchantid = request("cid") '''商户编号
keyvalue = request("mykey") '''商户密钥
orderid = request("orderid") '''订单编号
amount = request("totalmoney") '''订单金额
%>
<html>
<title>财付通支付</title>
<meta http-equiv="cache-control" content="no-cache"/>
<body onload="javascript:document.frm.submit()">
<% response.charset="gb2312" %>
<%
' 获取服务器日期,格式yyyymmdd
function cftgetserverdate
dim strtmp, iyear,imonth,idate
iyear = year(date)
imonth = month(date)
idate = day(date)
strtmp = cstr(iyear)
if imonth < 10 then
strtmp = strtmp & "0" & cstr(imonth)
else
strtmp = strtmp & cstr(imonth)
end if
if idate < 10 then
strtmp = strtmp & "0" & cstr(idate)
else
strtmp = strtmp & cstr(idate)
end if
cftgetserverdate = strtmp
end function
dim md5_sign
spid = merchantid ' 这里替换为您的实际商户号
sp_key = keyvalue ' sp_key是32位商户密钥, 请替换为您的实际密钥
' 下面是请求参数
cmdno = "1" ' 财付通支付为"1" (当前只支持 cmdno=1)
bill_date = cftgetserverdate ' 交易日期 (yyyymmdd)
bank_type = "0" ' 银行类型: 0 财付通
' 1001 招商银行
' 1002 中国工商银行
' 1003 中国建设银行
' 1004 上海浦东发展银行
' 1005 中国农业银行
' 1006 中国民生银行
' 1008 深圳发展银行
' 1009 兴业银行
desc = "" ' 商品名称
purchaser_id = "" ' 用户财付通帐号,如果没有可以置空
bargainor_id = spid ' 商户号
sp_billno = orderid ' 商户生成的订单号(最多32位)
' 重要:
' 交易单号(28位): 商户号(10位) + 日期(8位) + 流水号(10位), 必须按此格式生成, 且不能重复
' 如果sp_billno超过10位, 则截取其中的流水号部分加到transaction_id后部(不足10位左补0)
' 如果sp_billno不足10位, 则左补0, 加到transaction_id后部
transaction_id = spid & bill_date & "0000" & right(sp_billno,6)
total_fee = amount*100 ' 总金额, 分为单位
fee_type = "1" ' 货币类型: 1 – rmb(人民币) 2 - usd(美元) 3 - hkd(港币)
return_url = "" ' 财付通回调页面地址, (最长255个字符)
attach = "" ' 商户私有数据, 请求回调页面时原样返回
' 生成md5签名
sign_text = "cmdno=" & cmdno & "&date=" & bill_date & "&bargainor_id=" & bargainor_id &_
"&transaction_id=" & transaction_id & "&sp_billno=" & sp_billno &_
"&total_fee=" & total_fee & "&fee_type=" & fee_type & "&return_url=" & return_url &_
"&attach=" & attach & "&key=" & sp_key
md5_sign = ucase(asp_md5(sign_text)) ' 转换为大写
%>
<form name="frm" action="https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi">
<input type=hidden name="cmdno" value="<%=cmdno%>">
<input type=hidden name="date" value="<%=bill_date%>">
<input type=hidden name="bank_type" value="<%=bank_type%>">
<input type=hidden name="desc" value="<%=desc%>">
<input type=hidden name="purchaser_id" value="<%=purchaser_id%>">
<input type=hidden name="bargainor_id" value="<%=bargainor_id%>">
<input type=hidden name="transaction_id" value="<%=transaction_id%>">
<input type=hidden name="sp_billno" value="<%=sp_billno%>">
<input type=hidden name="total_fee" value="<%=total_fee%>">
<input type=hidden name="fee_type" value="<%=fee_type%>">
<input type=hidden name="return_url" value="<%=return_url%>">
<input type=hidden name="attach" value="<%=attach%>">
<input type=hidden name="sign" value="<%=md5_sign%>">
</form>
</body>
</html>
yeepay
1.hmac-md5.asp
复制代码 代码如下:
<%
' md5 code:
' "derived from the rsa data security, inc. md5 message-digest algorithm,
' as set out in the memo rfc1321."
'
' heavily modified from http://www.frez.co.uk/
'
' hmac code:
' modified from authorizenet sample scripts
%>
<%
'
' constants used in this script
'
const bits_to_a_byte = 8
const bytes_to_a_word = 4
const bits_to_a_word = 32
dim m_lonbits(30)
dim m_l2power(30)
m_lonbits(0) = clng(1)
m_lonbits(1) = clng(3)
m_lonbits(2) = clng(7)
m_lonbits(3) = clng(15)
m_lonbits(4) = clng(31)
m_lonbits(5) = clng(63)
m_lonbits(6) = clng(127)
m_lonbits(7) = clng(255)
m_lonbits(8) = clng(511)
m_lonbits(9) = clng(1023)
m_lonbits(10) = clng(2047)
m_lonbits(11) = clng(4095)
m_lonbits(12) = clng(8191)
m_lonbits(13) = clng(16383)
m_lonbits(14) = clng(32767)
m_lonbits(15) = clng(65535)
m_lonbits(16) = clng(131071)
m_lonbits(17) = clng(262143)
m_lonbits(18) = clng(524287)
m_lonbits(19) = clng(1048575)
m_lonbits(20) = clng(2097151)
m_lonbits(21) = clng(4194303)
m_lonbits(22) = clng(8388607)
m_lonbits(23) = clng(16777215)
m_lonbits(24) = clng(33554431)
m_lonbits(25) = clng(67108863)
m_lonbits(26) = clng(134217727)
m_lonbits(27) = clng(268435455)
m_lonbits(28) = clng(536870911)
m_lonbits(29) = clng(1073741823)
m_lonbits(30) = clng(2147483647)
m_l2power(0) = clng(1)
m_l2power(1) = clng(2)
m_l2power(2) = clng(4)
m_l2power(3) = clng(8)
m_l2power(4) = clng(16)
m_l2power(5) = clng(32)
m_l2power(6) = clng(64)
m_l2power(7) = clng(128)
m_l2power(8) = clng(256)
m_l2power(9) = clng(512)
m_l2power(10) = clng(1024)
m_l2power(11) = clng(2048)
m_l2power(12) = clng(4096)
m_l2power(13) = clng(8192)
m_l2power(14) = clng(16384)
m_l2power(15) = clng(32768)
m_l2power(16) = clng(65536)
m_l2power(17) = clng(131072)
m_l2power(18) = clng(262144)
m_l2power(19) = clng(524288)
m_l2power(20) = clng(1048576)
m_l2power(21) = clng(2097152)
m_l2power(22) = clng(4194304)
m_l2power(23) = clng(8388608)
m_l2power(24) = clng(16777216)
m_l2power(25) = clng(33554432)
m_l2power(26) = clng(67108864)
m_l2power(27) = clng(134217728)
m_l2power(28) = clng(268435456)
m_l2power(29) = clng(536870912)
m_l2power(30) = clng(1073741824)
'
' the main hmac function
'
function hmac(text,key)
dim hkey
dim ipad(63)
dim opad(63)
dim odata(79)
dim idata()
redim idata(64 + len(text) - 1)
if len(key)>64 then
hkey = calcmd5(key)
else
hkey = key
end if
dim x
for x=0 to 63
idata(x) = &h36
odata(x) = &h5c
ipad(x) = &h36
opad(x) = &h5c
next
for x=0 to len(hkey)-1
ipad(x) = ipad(x) xor asc(cstr(mid(hkey,x+1,1)))
opad(x) = opad(x) xor asc(cstr(mid(hkey,x+1,1)))
idata(x) = ipad(x) and &hff
odata(x) = opad(x) and &hff
next
for x=0 to len(text)-1
idata(64+x) = asc(cstr(mid(text,x+1,1))) and &hff
next
dim innerhashout
innerhashout = binl2byt(b_calcmd5(idata))
for x=0 to 15
odata(64+x) = innerhashout(x)
next
hmac = binl2hex(b_calcmd5(odata))
end function
'
' the main md5 function
'
function md5(smessage)
dim x, r
x = converttowordarray(smessage)
r = coremd5(x)
md5 = lcase(r(0) + r(1) + r(2) + r(3))
end function
'
' main auxilliary functions
'
function calcmd5(str)
calcmd5 = binl2hex(coremd5(str2binl(str)))
end function
function b_calcmd5(barray)
b_calcmd5 = coremd5(bytarray2binl(barray))
end function
function coremd5(x)
dim k
dim aa
dim bb
dim cc
dim dd
dim a
dim b
dim c
dim d
const s11 = 7
const s12 = 12
const s13 = 17
const s14 = 22
const s21 = 5
const s22 = 9
const s23 = 14
const s24 = 20
const s31 = 4
const s32 = 11
const s33 = 16
const s34 = 23
const s41 = 6
const s42 = 10
const s43 = 15
const s44 = 21
a = &h67452301
b = &hefcdab89
c = &h98badcfe
d = &h10325476
for k = 0 to ubound(x)-1 step 16
aa = a
bb = b
cc = c
dd = d
md5_ff a, b, c, d, x(k + 0), s11, &hd76aa478
md5_ff d, a, b, c, x(k + 1), s12, &he8c7b756
md5_ff c, d, a, b, x(k + 2), s13, &h242070db
md5_ff b, c, d, a, x(k + 3), s14, &hc1bdceee
md5_ff a, b, c, d, x(k + 4), s11, &hf57c0faf
md5_ff d, a, b, c, x(k + 5), s12, &h4787c62a
md5_ff c, d, a, b, x(k + 6), s13, &ha8304613
md5_ff b, c, d, a, x(k + 7), s14, &hfd469501
md5_ff a, b, c, d, x(k + 8), s11, &h698098d8
md5_ff d, a, b, c, x(k + 9), s12, &h8b44f7af
md5_ff c, d, a, b, x(k + 10), s13, &hffff5bb1
md5_ff b, c, d, a, x(k + 11), s14, &h895cd7be
md5_ff a, b, c, d, x(k + 12), s11, &h6b901122
md5_ff d, a, b, c, x(k + 13), s12, &hfd987193
md5_ff c, d, a, b, x(k + 14), s13, &ha679438e
md5_ff b, c, d, a, x(k + 15), s14, &h49b40821
md5_gg a, b, c, d, x(k + 1), s21, &hf61e2562
md5_gg d, a, b, c, x(k + 6), s22, &hc040b340
md5_gg c, d, a, b, x(k + 11), s23, &h265e5a51
md5_gg b, c, d, a, x(k + 0), s24, &he9b6c7aa
md5_gg a, b, c, d, x(k + 5), s21, &hd62f105d
md5_gg d, a, b, c, x(k + 10), s22, &h2441453
md5_gg c, d, a, b, x(k + 15), s23, &hd8a1e681
md5_gg b, c, d, a, x(k + 4), s24, &he7d3fbc8
md5_gg a, b, c, d, x(k + 9), s21, &h21e1cde6
md5_gg d, a, b, c, x(k + 14), s22, &hc33707d6
md5_gg c, d, a, b, x(k + 3), s23, &hf4d50d87
md5_gg b, c, d, a, x(k + 8), s24, &h455a14ed
md5_gg a, b, c, d, x(k + 13), s21, &ha9e3e905
md5_gg d, a, b, c, x(k + 2), s22, &hfcefa3f8
md5_gg c, d, a, b, x(k + 7), s23, &h676f02d9
md5_gg b, c, d, a, x(k + 12), s24, &h8d2a4c8a
md5_hh a, b, c, d, x(k + 5), s31, &hfffa3942
md5_hh d, a, b, c, x(k + 8), s32, &h8771f681
md5_hh c, d, a, b, x(k + 11), s33, &h6d9d6122
md5_hh b, c, d, a, x(k + 14), s34, &hfde5380c
md5_hh a, b, c, d, x(k + 1), s31, &ha4beea44
md5_hh d, a, b, c, x(k + 4), s32, &h4bdecfa9
md5_hh c, d, a, b, x(k + 7), s33, &hf6bb4b60
md5_hh b, c, d, a, x(k + 10), s34, &hbebfbc70
md5_hh a, b, c, d, x(k + 13), s31, &h289b7ec6
md5_hh d, a, b, c, x(k + 0), s32, &heaa127fa
md5_hh c, d, a, b, x(k + 3), s33, &hd4ef3085
md5_hh b, c, d, a, x(k + 6), s34, &h4881d05
md5_hh a, b, c, d, x(k + 9), s31, &hd9d4d039
md5_hh d, a, b, c, x(k + 12), s32, &he6db99e5
md5_hh c, d, a, b, x(k + 15), s33, &h1fa27cf8
md5_hh b, c, d, a, x(k + 2), s34, &hc4ac5665
md5_ii a, b, c, d, x(k + 0), s41, &hf4292244
md5_ii d, a, b, c, x(k + 7), s42, &h432aff97
md5_ii c, d, a, b, x(k + 14), s43, &hab9423a7
md5_ii b, c, d, a, x(k + 5), s44, &hfc93a039
md5_ii a, b, c, d, x(k + 12), s41, &h655b59c3
md5_ii d, a, b, c, x(k + 3), s42, &h8f0ccc92
md5_ii c, d, a, b, x(k + 10), s43, &hffeff47d
md5_ii b, c, d, a, x(k + 1), s44, &h85845dd1
md5_ii a, b, c, d, x(k + 8), s41, &h6fa87e4f
md5_ii d, a, b, c, x(k + 15), s42, &hfe2ce6e0
md5_ii c, d, a, b, x(k + 6), s43, &ha3014314
md5_ii b, c, d, a, x(k + 13), s44, &h4e0811a1
md5_ii a, b, c, d, x(k + 4), s41, &hf7537e82
md5_ii d, a, b, c, x(k + 11), s42, &hbd3af235
md5_ii c, d, a, b, x(k + 2), s43, &h2ad7d2bb
md5_ii b, c, d, a, x(k + 9), s44, &heb86d391
a = addunsigned(a, aa)
b = addunsigned(b, bb)
c = addunsigned(c, cc)
d = addunsigned(d, dd)
next
coremd5 = array(a,b,c,d)
end function
'
' screwball md5 functions
'
sub md5_ff(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_f(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
sub md5_gg(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_g(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
sub md5_hh(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_h(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
sub md5_ii(a, b, c, d, x, s, ac)
a = addunsigned(a, addunsigned(addunsigned(md5_i(b, c, d), x), ac))
a = rotateleft(a, s)
a = addunsigned(a, b)
end sub
function md5_f(x, y, z)
md5_f = (x and y) or ((not x) and z)
end function
function md5_g(x, y, z)
md5_g = (x and z) or (y and (not z))
end function
function md5_h(x, y, z)
md5_h = (x xor y xor z)
end function
function md5_i(x, y, z)
md5_i = (y xor (x or (not z)))
end function
'
' utility functions
'
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
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
function rotateleft(lvalue, ishiftbits)
rotateleft = lshift(lvalue, ishiftbits) or rshift(lvalue, (32 - ishiftbits))
end function
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
lresult = lresult xor lx8 xor ly8
end if
addunsigned = lresult
end function
function converttowordarray(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
function wordtohex(lvalue)
dim lbyte
dim lcount
for lcount = 0 to 3
lbyte = rshift(lvalue, lcount * bits_to_a_byte) and m_lonbits(bits_to_a_byte - 1)
wordtohex = wordtohex & right("0" & hex(lbyte), 2)
next
end function
function str2binl(str)
dim nblk
nblk = ( rshift((len(str) + 8), 6) ) + 1 ' number of 16-word blocks
dim blks()
redim blks(nblk*16 - 1)
dim x
for x=0 to nblk * 16 - 1
blks(x) = 0
next
dim aridx
for x = 0 to len(str)-1
aridx = rshift(x,2)
blks(aridx) = blks(aridx) or lshift(asc(cstr(mid(str,x+1,1))) and &hff, ((x mod 4) * 8))
next
blks(rshift(x,2)) = blks(rshift(x,2)) or lshift(&h80, ((x mod 4) * 8))
blks(nblk*16-2) = len(str) * 8
str2binl = blks
end function
function bytarray2binl(barray)
dim nblk
nblk = rshift((ubound(barray) + 8), 6) + 1 ' number of 16-word blocks
dim blks()
redim blks(nblk*16 - 1)
dim x
for x = 0 to nblk*16 - 1
blks(x) = 0
next
dim aridx
for x = 0 to ubound(barray)
aridx = rshift(x,2)
blks(aridx) = blks(aridx) or lshift( barray(x) and &hff, (x mod 4) * 8)
next
blks(rshift(x,2)) = blks(rshift(x,2)) or lshift(&h80, ((x mod 4) * 8))
blks(nblk*16-2) = (ubound(barray)+1) * 8
bytarray2binl = blks
end function
function binl2byt(binarray)
dim bytarray()
redim bytarray(((ubound(binarray)+1) * 4) - 1)
dim str
str = ""
dim x
for x = 0 to ((ubound(binarray)+1) * 4) -1
bytarray(x) = _
lshift(( rshift( binarray(rshift(x,2)), ((x mod 4)*8+4) ) and &hf ), 4) _
or _
(rshift(binarray(rshift(x,2)),((x mod 4)*8))) and &hf
next
binl2byt = bytarray
end function
function binl2hex(binarray)
dim hex_tab
hex_tab = "0123456789abcdef"
dim str
str = ""
dim x
for x=0 to ((ubound(binarray)+1) * 4) - 1
str = str + mid(hex_tab,( rshift(binarray(rshift(x,2)), ((x mod 4)*8+4)) and &hf )+1, 1) + _
mid(hex_tab,( rshift(binarray(rshift(x,2)), ((x mod 4)*8)) and &hf )+1, 1)
next
binl2hex = str
end function
%>
2.send.asp
复制代码 代码如下:
<!-- #include file="hmac-md5.asp" -->
<%
dim merchantid
dim keyvalue
merchantid = request("cid") '''商户编号
keyvalue = request("mykey") '''商户密钥
orderid = request("orderid") '''订单编号
amount = request("totalmoney") '''订单金额
%>
<%
dim merchantcallbackurl
'设定秘钥,其中正式的merchantid以及秘钥value 需要从yeepay易宝提供给商家的商家自助服务系统获得
merchantid = merchantid '测试使用 merchant id = "1001001"
keyvalue = keyvalue '测试使用 keyvalue = "key"
merchantcallbackurl = "" '用户完成交易完成后, 控制应用返回到商家自己的url
%>
<!-- #include file="yeepaycommon.asp" -->
<%
dim orderid
dim productdesc
dim productcat
dim productid
dim cur
dim smctproperties
dim snewstring
dim frpid
'商家设置用户购买商品的支付信息
orderid=orderid '商家的交易定单号此参数可选,但不能有重复(如果不输入yeepay会自动帮助商家生成一个订单号)
productid = "0" '商品id(尽量清楚填写,方便以后统计订单)
amount=amount '购买金额(必须)
cur="cny" '货币单位(固定不需要修改,现在一般只会支持人民币交易)
productdesc = "" '商品描述(可保持为空)
productcat = "" '商品种类(可保持为空)
'商家可以把一些辅助信息放在mp列表中,当从yeepay易宝平台返回时,还可以原样取出商家设定的一些信息。可以提供商家临时保存信息的功能
smctproperties = "" '(可保持为空)
'如果直接到yeepay网关设定为空即可,而在商家端选择银行的情况下请参见银行列表
frpid="" '(可选)
'调用签名函数生成签名串
snewstring = getreqhmacstring(orderid,amount,cur,productid,productcat,productdesc,merchantcallbackurl,smctproperties,frpid)
%>
<html>
<head>
<title>易宝支付</title>
</head>
<body onload="document.yeepay.submit()">
<form name="yeepay" action="<%=nodeauthorizationurl%>" method="post">
<input type="hidden" name="p0_cmd" value="<%=messagetype%>">
<input type="hidden" name="p1_merid" value="<%=merchantid%>">
<input type="hidden" name="p2_order" value="<%=orderid%>">
<input type="hidden" name="p3_amt" value="<%=amount%>">
<input type="hidden" name="p4_cur" value="<%=cur%>">
<input type="hidden" name="p5_pid" value="<%=productid%>">
<input type="hidden" name="p6_pcat" value="<%=productcat%>">
<input type="hidden" name="p7_pdesc" value="<%=productdesc%>">
<input type="hidden" name="p8_url" value="<%=merchantcallbackurl%>">
<input type="hidden" name="p9_saf" value="<%=addressflag%>">
<input type="hidden" name="pa_mp" value="<%=smctproperties%>">
<input type="hidden" name="pd_frpid" value="<%=frpid%>">
<input type="hidden" name="hmac" value="<%=snewstring%>">
</form>
</body>
</html>
3.yeepaycommon.asp
复制代码 代码如下:
<%
dim mctsdk
dim nodeauthorizationurl
dim messagetype
dim addressflag
nodeauthorizationurl = "https://www.yeepay.com/app-merchant-proxy/node" '扣款请求url 无需更改
messagetype="buy" '消息类型
addressflag="0" '需要填写送货信息 0:不需要 1:需要
function getreqhmacstring(orderid,amount,cur,productid,productcat,productdesc,merchantcallbackurl,smctproperties,frpid)
dim sbold
'进行加密串处理,一定按照下列顺序进行
sbold=""
sbold = sbold + messagetype
sbold = sbold + merchantid
sbold = sbold + orderid
sbold = sbold + cstr(amount)
sbold = sbold + cur
sbold = sbold + productid
sbold = sbold + productcat
sbold = sbold + productdesc
sbold = sbold + merchantcallbackurl
sbold = sbold + addressflag
sbold = sbold + smctproperties
sbold = sbold + frpid
getreqhmacstring = hmac(sbold,keyvalue)
end function
function getcallbackhmacstring(scmd,serrorcode,strxid,orderid,amount,productid,userid,mp,btype)
dim sbold
'取得加密前的字符串
sbold = ""
sbold = sbold + cstr(merchantid)
sbold = sbold + scmd
sbold = sbold + serrorcode
sbold = sbold + strxid
sbold = sbold + amount
sbold = sbold + cur
sbold = sbold + productid
sbold = sbold + orderid
sbold = sbold + userid
sbold = sbold + mp
sbold = sbold + btype
getcallbackhmacstring = hmac(sbold,keyvalue)
end function
function checkhmac(scmd,serrorcode,strxid,orderid,amount,productid,userid,mp,btype,hmac)
if(hmac=getcallbackhmacstring(scmd,serrorcode,strxid,orderid,amount,productid,userid,mp,btype)) then
checkhmac = true
else
checkhmac = flase
end if
end function
'取得返回串中的所有参数
sub getcallbackvalue(byref scmd,byref serrorcode,byref strxid,byref amount,byref cur,byref productid,byref orderid,byref userid,byref mp,byref btype,byref svrhmac)
scmd = request.querystring("r0_cmd")
serrorcode = request.querystring("r1_code")
strxid = request.querystring("r2_trxid")
amount = request.querystring("r3_amt")
cur = request.querystring("r4_cur")
productid = request.querystring("r5_pid")
orderid = request.querystring("r6_order")
userid = request.querystring("r7_uid")
mp = request.querystring("r8_mp")
btype = request.querystring("r9_btype")
svrhmac = request.querystring("hmac")
end sub
%>
下一篇: 说的都对,唠的很嗨