文件名称:as3.0 IDEA数据加密方法
文件大小:6KB
文件格式:AS
更新时间:2015-01-03 11:45:42
as3 网络加密 IDEA算法 flash
package socket{ import flash.utils.ByteArray; public class IDEA{ public var ory:ByteArray; public var ary:Array; public var dekey:Array; public var enkey:Array; public function IDEA() { ary=new Array(); dekey=new Array(); enkey=new Array(); ory=new ByteArray(); } public function TraceEnKey():void{ trace(enkey.length,enkey); } public function TraceDeKey():void{ trace(dekey.length,dekey); } public function TraceOry():void{ trace(ory); } public function TraceAry():void{ trace(ary); } public function Low16(mm:uint):uint { return (mm&0xffff); } public function inv(mm:uint):uint { var t0:uint; var t1:uint; var q:int; var yy:uint; if (mm<=1) { return Low16(mm); } var long:uint=new uint(0x10001); t1=Low16(long/mm); yy=Low16(long%mm); if (yy==1) { return Low16(1-t1); } t0=1; do { q=mm/yy; mm=mm%yy; t0+=q*t1; if (mm==1) { return Low16(t0); } q=yy/mm; yy=yy%mm; t1+=q*t0; } while (yy!=1); return Low16(1-t1); } public function en_key_idea(userkey:Array,zz:Array):void { var i:int;// 进行16位运算 var j:int; var iu:int=new int(); for (i=0; i<8; i++) { zz[i]=Low16(userkey[i]); } iu=0; for (j=0; i<52; i++) { j++; zz[iu+j+7]=Low16((zz[iu+(j&7)]<<9)|(zz[iu+(j+1&7)]>>7)); iu+=j&8; j&=7; } }