首页 > 其他 > 详细

as3 代码加解密

时间:2014-08-06 14:34:11      阅读:505      评论:0      收藏:0      [点我收藏+]
private var loader:URLLoader;
...
private function init():void
{
   loader = new URLLoader;
   req=URLRequest = new URLRequest("1.txt");
  loader.load(req);
  loader.addEventListener(Event.COMPLETE,oncomlete);         
}
private function oncomplete(e:Event):void
{
  var str:String=loader.data;
  trace("src///////");
  str=secret(str);
  trace("secret///////\n"+str);
  str=unsecret(str);
  trace("unsecret//////////////\n"+str);
      
}

private var add_key:Array=[800,650,400,525,100,250]//间距大于122(z的unicode值)
private var range:Array=[65,91,97,123]//65,70,75,91,97,100,123
private var xor_key:Array=[0xaa,0xbb] private function secret(src:String):String { var res:String=""; var i:int,len:int,unicode:int; len=src.length for(i=0;i<len;i++) { unicode=str.charCodeAt(i); var idx=index(unicode); res+=String.fromCharCode(xor(add_key[idx]+unicode+random(i))) } return res; } i private function xor(v:int):int { var i:int,len:int; len=xor_key.length for(i=0;i<len;i++) { v^=xor_key[i]; } return v; } private function random(i:int):int { swicth(i%4) { case 0: if(i%9==0) return((1-Math.sin(i))*(i%100)>>0); else return((1-Math.sin(i))*(i%200)>>0); case 1: return ((1-Math.cos(i))*(i%300)>>0); case 2: return ((1-Math.cos(i)*Math.sin(i))*(i%400)>>0); case 3 if(i%3==0) return((1-Math.sin(i)*Math.cos(i)*Math.cos(i))*(i%500)>>0); else return((1-Math.sin(i)*Math.cos(i)*Math.cos(i))*(i%600)>>0); }
return 1; }
private function index(u:int):int { if(u>64&&u<91||u>96&&u<123) { var i:int,len:int; len=range.length-1; for(i=0;i<len;i++) { if(u>=range[i]&&u<range[i+1]) break; } return i } else return 5 } private function index2(u:int):int { var i:int,len:int; len=add_key.length-1; for(i=0;i<len;i++) { if(u>=add_key[i]&&u<=add_key[i]+123) break; } return u-add_key[i]; } private function unsecret(src:String):String { var res:String=""; var i:int,len:int; var u:int; len=src.length; for(i=0;i<len;i++) { u=xor(src.charCodeAt(i)-random(i)); u=index2(u); res+=String.formCharCode(u); } return res; }

 

[65,70,80,91,97,110,123]

as3 代码加解密,布布扣,bubuko.com

as3 代码加解密

原文:http://www.cnblogs.com/white-eyes/p/3894341.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!