翻译一段javascript的简单程序(150分)

  • 主题发起人 主题发起人 heipi2003
  • 开始时间 开始时间
H

heipi2003

Unregistered / Unconfirmed
GUEST, unregistred user!
Javascript==>Delphi
function a(h)
{var s='',g,w,z,i;
for(g=0;g<h.length;g++)
{w=h.charAt(g);//单个字节
z=r.indexOf(w);
if(z>-1)
{i=((z+1)%e-1);
if(i<=0){i+=e}
s+=r.charAt(i-1)
}
else
{s+=w}
}
t+=s};
参考参数:
r="wVl!p8L5D/"j0N+(<&amp;=Fx9C)H|?qJfgcIEtOT1rzMye-6okb2.7nhP4S#aA;dBGuWU/3s>m:i$ v";
e=75;
t="";
对javascript不甚了解,indexOf(w)是什么意思?%为取模,弄了半天没弄出来:(
哪位大哥帮忙呀
 
相當delphi的pos(),但JavaScript裡的indexOf()是String類型的一個方法.它的基點是0.
 
function a(h):String;
var
s,t:String;
g,z,i:Integer;
w:Char;
begin
s:='';
t:='';
for g := 0 to Length(h) do
begin
w:=h[g];
z=pos(w,r);
if(z>0) then
begin
i:=((z+1) mod e) -1 ;
if(i<=0) i:=i+e;
end
else
s:=s+w;
end
t:=t+s;
end;
 
Return?Result:=?
Pos('a','ab')=0 and Pos('a','bc') 呀,好像不通用的:(
我写的和楼上写的一样,好像通不过,我试试
 
解码如下页面:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="expires" content="2"><meta http-equiv="imagetoolbar" content="no"> <script type="text/javascript">var $sql = 'bjo6r1he3r5f9j47g';</script></head><body><script language="JavaScript" type="text/javascript"><!--
var t=75,o="Tuc3o8M02bW4.5v|>)n$GxUsf/kwtFzO=H<Jl;9S#&amp;+p- EDiIg(aj61my!:7N?LqVrBhACdeP/"",w="",g="";eval(unescape("%66%75%6E%63%74%69%6F%6E%20%78%28%64%29%7B%76%61%72%20%62%3D%27%27%2C%6E%2C%6A%2C%6C%2C%75%3B%66%6F%72%28%6E%3D%30%3B%6E%3C%64%2E%6C%65%6E%67%74%68%3B%6E%2B%2B%29%7B%6A%3D%64%2E%63%68%61%72%41%74%28%6E%29%3B%6C%3D%6F%2E%69%6E%64%65%78%4F%66%28%6A%29%3B%69%66%28%6C%3E%2D%31%29%7B%75%3D%28%28%6C%2B%31%29%25%74%2D%31%29%3B%69%66%28%75%3C%3D%30%29%7B%75%2B%3D%74%7D%62%2B%3D%6F%2E%63%68%61%72%41%74%28%75%2D%31%29%7D%65%6C%73%65%7B%62%2B%3D%6A%7D%7D%77%2B%3D%62%7D%3B%66%75%6E%63%74%69%6F%6E%20%69%69%69%28%29%7B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%77%29%3B%67%3D%22%22%7D"));x("JeI|EIeHT$i1uohTEfF!;PHT-8fIFI8$7jWf8;cFP9;P/F7v-U9F8-7v-U9O I$ePU7mmmmm9/I;FPB7C;-Aja8-j3IF!HS2,/I$IfA8-j3IF!HS2,fF!;PHon9T)JFjW;PEW8BePBHT2TE3P;;f-j3I$(HTmTE3P;;-jeeI$(HTbTEtIeFAHTo22TEW(38;8BHT&amp;zzzzzzTE8$y8cfP8|PBHTFAIf5fF!;P53cBf8BH'Aj$e'TE8$3;I3wHTFAIf5fF!;P5|IfIWI;
if!H'AIeeP$'T)JFBEW(38;8BHT&amp;.NvzS1TEj;I($HT3P$FPBT)JFe)J/8$FE/j3PHTCBIj;,<P;|PFI3j,fj$f fPBI/TE38;8BHT&amp;zzzzzzTEfIOPHT mT)/"B8FP3FPeEW!Ej$Ec$BP(IfFPBPeE|PBfI8$E8/Jk/8$F)JkFe)JkFB)JFBEW(38;8BHT&amp;M.SNd.TEj;I($HT3P$FPBT)JFe)J/8$FE/j3P");x("HTCBIj;,<P;|PFI3j,fj$f fPBI/TE38;8BHT&amp;zzzzzzTEfIOPHTpmT)JW)<u0qExcjBeJkW)Jk/8$F)JkFe)JkFB)JkFjW;P)JkeI|)Jf3BI-FE;j$(cj(PHTlj|j#3BI-FTEF!-PHTFPUFk6j|jf3BI-FT)J: /nI/ae83cy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!-PHTFPUFk6j|jf3BI-FT)/r/r/nJ: /r/r/n|jBEGj;BPje!EHE29/r/r/n/r/r/nI/Eae83cyP$F5Iyj(Pfn{E/r/r/n/tBf;FEHE$PtEgyj(Pan9/r/r/n/tBf;F5fB3EHE'BPeIBP3Fb5(I/'9/r/r/n}/r/r/n/r/r/n/c$3FI8$EOI--!bIAan{/r/r/n/tI/EaGj;BPje!EHHE2n{/r/r/n/t/tGj;BPje!EHEm9/r/r/n/t/tI/Eae83cyP$F5I");x("yj(Pfn{/r/r/n/t/t/te83cyP$F['BPeIBP3F']5fB3H'BPeIBP3Fb5(I/'9/r/r/n/t/t/tF8-5;83jFI8$5BP-;j3Pa'v2-8I$Ff5-A-L388wIPHbIA+fPFH'pGfV;n9/r/r/n/t/t}EP;fPE{/r/r/n/t/t/tF8-5;83jFI8$5ABP/H'v2-8I$Ff5-A-L388wIPHbIA+fPFH'pGfV;9/r/r/n/t/t}/r/r/n/t}/r/r/n}/r/r/nkk )/r/r/nJkf3BI-F)JW8e!E8$y8cfP8|PBHTOI--!bIAanTE8$y8cfPy8|PHTOI--!bIAanT)J-E8$y8cfP8|PBHTOI--!bIAanTE8$y8cfPy8|PHTOI--!bIAanT)EJWB)JWB)JWB)JWB)JWB)JWB)JWB)JeI|Ej;I($HT3P$FPBT)EJIy(EfB3HTBPeIBP3Fm5(I/TE$jyPHTBPeIBP3FTEtIeFAHTmv2TEAPI(AFHTv2TEj;FHTTEW8");x("BePBHT2TE8$y8cfP8|PBHTOI--!bIAanT)EJkeI|)EJk-)");iii();document.write(g);g="";//--></script><noscript>To display this page you need a browser with JavaScript support.</noscript></body></html>
要取出如下参数:cookie=2ih&amp;set=bjo6r1he3r5f9j47g
如下函数部分解密
%66%75%6E%63%74%69%6F%6E%20%78%28%64%29%7B%76%61%72%20%62%3D%27%27%2C%6E%2C%6A%2C%6C%2C%75%3B%66%6F%72%28%6E%3D%30%3B%6E%3C%64%2E%6C%65%6E%67%74%68%3B%6E%2B%2B%29%7B%6A%3D%64%2E%63%68%61%72%41%74%28%6E%29%3B%6C%3D%6F%2E%69%6E%64%65%78%4F%66%28%6A%29%3B%69%66%28%6C%3E%2D%31%29%7B%75%3D%28%28%6C%2B%31%29%25%74%2D%31%29%3B%69%66%28%75%3C%3D%30%29%7B%75%2B%3D%74%7D%62%2B%3D%6F%2E%63%68%61%72%41%74%28%75%2D%31%29%7D%65%6C%73%65%7B%62%2B%3D%6A%7D%7D%77%2B%3D%62%7D%3B%66%75%6E%63%74%69%6F%6E%20%69%69%69%28%29%7B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%77%29%3B%67%3D%22%22%7D
为:
function x(d){var b='',n,j,l,u;for(n=0;n<d.length;n++){j=d.charAt(n);l=o.indexOf(j);
if(l>-1){u=((l+1)%t-1);
if(u<=0){u+=t}b+=o.charAt(u-1)}else
{b+=j}}w+=b};function iii(){document.write(w);g=""}
如何转换出源代码?应该不是特别难吧,那个好心把这个函数转换一下。
Delphi中的pos和JS中的indexof区别很大的吧
 
是不难吧,:)
是用你的函数把
%66%75%6E%63%74%69%6F%6E%20%78%28%64%29%7B%76%61%72%20%62%3D%27%27%2C%6E%2C%6A%2C%6C%2C%75%3B%66%6F%72%28%6E%3D%30%3B%6E%3C%64%2E%6C%65%6E%67%74%68%3B%6E%2B%2B%29%7B%6A%3D%64%2E%63%68%61%72%41%74%28%6E%29%3B%6C%3D%6F%2E%69%6E%64%65%78%4F%66%28%6A%29%3B%69%66%28%6C%3E%2D%31%29%7B%75%3D%28%28%6C%2B%31%29%25%74%2D%31%29%3B%69%66%28%75%3C%3D%30%29%7B%75%2B%3D%74%7D%62%2B%3D%6F%2E%63%68%61%72%41%74%28%75%2D%31%29%7D%65%6C%73%65%7B%62%2B%3D%6A%7D%7D%77%2B%3D%62%7D%3B%66%75%6E%63%74%69%6F%6E%20%69%69%69%28%29%7B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%77%29%3B%67%3D%22%22%7D
解成
cookie=2ih&amp;set=bjo6r1he3r5f9j47g
?
 
pos 是取字符的位置,而indexof是取那个位置的字符
 
function a(h:String):String;
var
s,t,r:String;
g,z,i:Integer;
w:Char;
e:Integer;
begin
s:='';
t:='';
e:=5;
r:='wVl!p8L5D/"j0N+(<&amp;=Fx9C)H|?qJfgcIEtOT1rzMye-6okb2.7nhP4S#aA;dBGuWU/3s>m:i$ v';
for g := 0 to Length(h) do
begin
w:=h[g];
z:=pos(w,r);
if(z>0) then
begin
i:=((z+1) mod e);
if(i<=0) then
i:=i+e;
end
else
s:=s+w;
end;
t:=t+s;
result:=t;
end;
 
??还是通不过?
 
后退
顶部