jeudi 29 septembre 2016

Encryption not returning value

package {
import flash.display.Sprite;
import flash.text.TextField;
public class FlashTest extends Sprite {
    public function FlashTest() {

        var tf:TextField = new TextField();
        tf.text=encrypt("test");
        tf.x = tf.y = 100;
        tf.height = 20;
        tf.background = true;
        tf.backgroundColor = 0xdddd;
        addChild(tf);



    const DELTA:int = -1640531527;



    const ROUNDS:int = 32;






   var key:String = "alphanumeric";



   var token:String = "alphanumeric01";



   function EncryptionHandler(param1:String = "alphanumeric", param2:String = "alphanumeric01")

  {

     key = param1;

     token = param2;

  }



   function encrypt(param1:String) : String

  {

     return _encrypt(param1,key,token);

  }



   function decrypt(param1:String) : String

  {

     return _decrypt(param1,key);

  }



   function setKeyTokenPair(param1:String, param2:String) : void

  {

     this.key = param1;

     this.token = param2;

  }



   function _encrypt(param1:String, param2:String, param3:String) : String

  {

     var _loc10_:* = NaN;

     if(param1.length == 0)

     {

        return "";

     }

     var _loc5_:Array = this.charsToLongs(this.strToChars(param1));

     var _loc9_:Array = this.charsToLongs(this.hexToChars(param2));

     var _loc8_:Number = _loc5_.length;

     if(_loc8_ % 2 == 1)

     {

        _loc8_++;

        _loc5_[_loc8_] = 0;

     }

     var _loc7_:Array = new Array(2);

     var _loc4_:Array = new Array(_loc5_.length);

     _loc10_ = 0;

     while(_loc10_ < _loc5_.length)

     {

        _loc7_ = this.mcrypt_encrypt(_loc9_,!!isNaN(_loc5_[_loc10_])?0:_loc5_[_loc10_],!!isNaN(_loc5_[_loc10_ + 1])?0:_loc5_[_loc10_ + 1]);

        _loc4_[_loc10_] = _loc7_[0];

        _loc4_[_loc10_ + 1] = _loc7_[1];

        _loc10_ = Number(_loc10_ + 2);

     }

     var _loc6_:String = this.charsToHex(this.longsToChars(_loc4_));

     return param3 + "" + _loc6_;

  }



   function mcrypt_encrypt(param1:Array, param2:Number, param3:Number) : Array

  {

     var _loc4_:* = 0;

     while(_loc4_ != -957401312)

     {

        param2 = Math.floor(param2 + ((param3 << 4 ^ param3 >>> 5) + param3 ^ _loc4_ + param1[_loc4_ & 3]));

        _loc4_ = Number(int(_loc4_ + -1640531527));

        param3 = Math.floor(param3 + ((param2 << 4 ^ param2 >>> 5) + param2 ^ _loc4_ + param1[_loc4_ >>> 11 & 3]));

     }

     return [param2,param3];

  }



   function mcrypt_decrypt(param1:Array, param2:Number, param3:Number) : Array

  {

     var _loc4_:* = -957401312;

     while(_loc4_)

     {

        param3 = int(param3 - ((param2 << 4 ^ param2 >>> 5) + param2 ^ _loc4_ + param1[_loc4_ >>> 11 & 3]));

        _loc4_ = Number(int(_loc4_ - -1640531527));

        param2 = int(param2 - ((param3 << 4 ^ param3 >>> 5) + param3 ^ _loc4_ + param1[_loc4_ & 3]));

     }

     return [param2,param3];

  }



   function _decrypt(param1:String, param2:String) : String

  {

     var _loc4_:* = null;

     var _loc6_:* = null;

     var _loc5_:* = null;

     var _loc3_:* = null;

     var _loc7_:* = NaN;

     if(param1.substr(0,1) == "<")

     {

        return param1;

     }

     if(param1.length == 0)

     {

        return "";

     }

     _loc4_ = this.charsToLongs(this.hexToChars(param1));

     _loc6_ = this.charsToLongs(this.hexToChars(param2));

     _loc5_ = new Array(2);

     _loc3_ = new Array(_loc4_.length);

     _loc7_ = 0;

     while(_loc7_ < _loc4_.length)

     {

        _loc5_ = this.mcrypt_decrypt(_loc6_,_loc4_[_loc7_],_loc4_[_loc7_ + 1]);

        _loc3_[_loc7_] = _loc5_[0];

        _loc3_[_loc7_ + 1] = _loc5_[1];

        _loc7_ = Number(_loc7_ + 2);

     }

     return this.charsToStr(this.longsToChars(_loc3_));

  }



   function charsToHex(param1:Array) : String

  {

     var _loc4_:* = NaN;

     var _loc2_:String = new String("");

     var _loc3_:Array = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");

     _loc4_ = 0;

     while(_loc4_ < param1.length)

     {

        _loc2_ = _loc2_ + (_loc3_[param1[_loc4_] >> 4] + _loc3_[param1[_loc4_] & 15]);

        _loc4_++;

     }

     return _loc2_;

  }



   function hexToChars(param1:String) : Array

  {

     var _loc3_:Number = NaN;

     var _loc2_:Array = [];

     _loc3_ = param1.substr(0,2) == "0x"?2:0;

     while(_loc3_ < param1.length)

     {

        _loc2_.push(parseInt(param1.substr(_loc3_,2),16));

        _loc3_ = _loc3_ + 2;

     }

     return _loc2_;

  }



   function charsToLongs(param1:Array) : Array

  {

     var _loc9_:* = NaN;

     var _loc2_:Number = NaN;

     var _loc3_:Number = NaN;

     var _loc5_:Number = NaN;

     var _loc6_:Number = NaN;

     var _loc7_:Number = Math.ceil(param1.length / 4);

     var _loc4_:Array = [];

     var _loc8_:* = 0;

     _loc9_ = 0;

     while(_loc9_ < _loc7_)

     {

        _loc8_ = Number(_loc9_ * 4);

        _loc2_ = param1[_loc8_] == undefined?0:param1[_loc8_];

        _loc3_ = param1[_loc8_ + 1] == undefined?0:param1[_loc8_ + 1];

        _loc5_ = param1[_loc8_ + 2] == undefined?0:param1[_loc8_ + 2];

        _loc6_ = param1[_loc8_ + 3] == undefined?0:param1[_loc8_ + 3];

        _loc4_[_loc9_] = Number((_loc2_ << 24) + (_loc3_ << 16) + (_loc5_ << 8) + _loc6_);

        _loc9_++;

     }

     return _loc4_;

  }



   function longsToChars(param1:Array) : Array

  {

     var _loc4_:* = NaN;

     var _loc3_:Array = [];

     var _loc2_:Number = param1.length;

     var _loc5_:* = 0;

     _loc4_ = 0;

     while(_loc4_ < _loc2_)

     {

        _loc5_++;

        _loc3_[_loc5_] = param1[_loc4_] >>> 24 & 255;

        _loc5_++;

        _loc3_[_loc5_] = param1[_loc4_] >>> 16 & 255;

        _loc5_++;

        _loc3_[_loc5_] = param1[_loc4_] >>> 8 & 255;

        _loc5_++;

        _loc3_[_loc5_] = param1[_loc4_] & 255;

        _loc4_++;

     }

     return _loc3_;

  }



   function charsToStr(param1:Array) : String

  {

     var _loc4_:* = NaN;

     var _loc3_:String = new String();

     var _loc2_:Number = param1.length;

     _loc4_ = 0;

     while(_loc4_ < _loc2_)

     {

        _loc3_ = _loc3_ + String.fromCharCode(param1[_loc4_]);

        _loc4_++;

     }

     return _loc3_ as String;

  }



   function strToChars(param1:String) : Array

  {

     var _loc4_:* = NaN;

     var _loc3_:Array = [];

     var _loc2_:Number = param1.length;

     _loc4_ = 0;

     while(_loc4_ < _loc2_)

     {

        _loc3_.push(param1.charCodeAt(_loc4_));

        _loc4_++;

     }

     return _loc3_;

  }





   function changeKey(param1:String, param2:String) : String

  {

     return param1.substr(0,8) + param2.substr(8,24);

  }



   function toString() : String

  {

     return "[WIN_apiTEA]";

  }

    }
}}

I'm trying to get it to show the encrypted form of the "test" string. What am I doing wrong? This document is apart of a larger source but, I've omitted and crated this small sample. But, the same problem lies. When the encrypt, _encrypt, decrypt, _decrypt functions are called. They return nothing.

Aucun commentaire:

Enregistrer un commentaire