帮将vbscript转为javascript,并注解思路,算法
<%
Function EncryptStr(ID,Str)
Dim i,L,n
Dim TmpID,mStr,mStr1
TmpID=ID
L=len(ID)
TmpID= ""
mStr = ""
for i=1 to L
mStr=Chr(AscB(MidB(ID,L-i+1,1))+i mod 256)
TmpID = TmpID+mStr
Next
N=len(Str)
mStr = ""
mStr1= ""
for i=1 to n
mStr = Chr(Asc(Mid(Str,i,1)) Xor Asc(Mid(TmpID,((i-1) mod L)+1,1)))
mStr1 = mStr1+mStr
Next
EncryptStr=mStr1
end Function
Function ZH36(C)
Dim i,L
Dim Str
Str=Chr((Asc(Mid(C,1,1))\36)+Asc("0"))
i= Asc(Mid(c,1,1)) mod 36
if i<10 then
Str=Str+CStr(i)
else
Str=Str+Chr(Asc("A")+i-10)
end if
ZH36 = Str
End Function
Function EncryptPassword(ID,Str)
Dim i,L
Dim Str1,Str2
L=len(Str)
STR1=""
FOR I=L TO 1 Step -1
Str1=STR1+Mid(STR,I,1)
Next
if L<16 then
Str1=Str1+" "
for i=L+1 to 16
Str1=Str1+chr(Asc(Mid(Str1,1,1))+i)
Next
L = 16
end if
Str1=Mid(Str1,2,L)+Mid(Str1,1,1)
ID=ID+CStr(len(Str))
EncryptPassword=EncryptStr(ID,Str1)
L=len(EncryptPassword)
STR2=""
FOR I=1 TO L
Str2=STR2+ZH36(Mid(EncryptPassword,I,1))
Next
EncryptPassword=Str2
end Function
%>
//解密字符串
Function UnEncryptDStr(ID,Str:string):string;
function Z36ToC(C:string):char; //将两个36进制转成一个字符
var
I:integer;
begin
i:=StrToint(copy(c,1,1))*36;
if copy(c,2,1)>'9' then
i:=i+ord(c[2])-ord('A')+10
else
i:=i+strtoint(copy(c,2,1));
Result:=chr(i);
end;
var
i,StrLen,L:integer;
EnStr:string;
begin
//将STR从两位 0..9,A..Z 36串转单字节串。
L:=Length(str);
if (L<32) or ((L Mod 2)<>0) then //计密串错误
exit;
L:=L div 2;
EnStr:='';
for i:=1 to L do
begin
EnStr:=EnStr+Z36ToC(copy(str,i*2-1,2));
end;
//加密ID不足10位,补到10位
L:=length(Id);
if L<10 then
for i:=L-1 to 10 do
ID:=ID+chr(Ord('0')+i-1);
EnStr:=EncryptStr(ID,EnStr); //将ID与STR做Xor解密
StrLen:=ord(EnStr[1]); //实际明文的长度
Result:=Copy(EnStr,2,StrLen);
end;
一加密一解密,我看不懂,哪位帮转给50分
最重要是解密部,例加密手机为:1D0B0909020B090A08251U2534353A3B3839 ,请给出正确的解密手机号,并帮我讲解一下!
上面的ID为lin123。