function decodeMobile(g,f){
var h="";
for(a in b=g.substr(1).split("%")){
b[a]=parseInt(b[a],1<<(1<<1<<1));
}

while(b.length>0){
d=0;
for(a in b){
t=b[a]+d*f;
b[a]=parseInt(t/(1<<(1<<3)));
d=t%(1<<(1<<3));
}
if(d<16){
h="%0"+d.toString(16)+h;
}else{
h="%"+d.toString(16)+h;
}
for(a in b){
while(b[a]==0){
b.shift();
}
break;
}
}
return h;
}谁帮我修改成asp,vbscript服务器端函数?

解决方案 »

  1.   


    Function decodeMobile(g,f)
      response.Write(g&"<br>")
      Dim h, b, a, aa, d, t
      h=""
      b = Split(Mid(g, 2), "%")
      for a = 0 to ubound(b)
    b(a) = HcD(b(a))
      next
      for aa = 0 to ubound(b)
        d=0
    for a = 0 to ubound(b)
      t = b(a)+d*f
      b(a) = int(t/256)
      d = t mod 256
    next
    if d>0 then
      if d<16 then
    h="%0"+BcH(cBit(d))+h
      else
        h="%"+BcH(cBit(d))+h
      end if
    end if
      next
      response.Write(h&"<br>")
      decodeMobile = h
    End Function
    function HcD(num)'十六进制转十进制
    HcD=cDec(HcB(num))
    end functionfunction HcB(num)'十六进制转二进制
    if len(num)>0 then
    HcBstr=""
    for i=1 to len(num)
    select case (mid(num,i,1))
       case "0" HcBstr=HcBstr&"0000"
       case "1" HcBstr=HcBstr&"0001"
       case "2" HcBstr=HcBstr&"0010"
       case "3" HcBstr=HcBstr&"0011"
       case "4" HcBstr=HcBstr&"0100"
       case "5" HcBstr=HcBstr&"0101"
       case "6" HcBstr=HcBstr&"0110"
       case "7" HcBstr=HcBstr&"0111"
       case "8" HcBstr=HcBstr&"1000"
       case "9" HcBstr=HcBstr&"1001"
       case "A" HcBstr=HcBstr&"1010"
       case "B" HcBstr=HcBstr&"1011"
       case "C" HcBstr=HcBstr&"1100"
       case "D" HcBstr=HcBstr&"1101"
       case "E" HcBstr=HcBstr&"1110"
       case "F" HcBstr=HcBstr&"1111"
    end select
    next
    end if
    HcB=HcBstr
    end functionfunction cDec(num)'二进制转十进制
    cDecstr=0
    if len(num)>0 and isnumeric(num) then
    for inum=0 to len(num)-1
    cDecstr=cDecstr+2^inum*cint(mid(num,len(num)-inum,1))
    next
    end if
    cDec=cDecstr
    end functionfunction BcH(num)'二进制转十六进制
    BcH=Hex(cDec(num))
    end functionfunction cBit(num)'十进制转二进制
    cBitstr=""
    if len(num)>0 and isnumeric(num) then
    do while not num \ 2 < 1
    cBitstr=(num mod 2) &cBitstr
    num=num \ 2
    loop
    end if
    cbit=num&cBitstr
    end function