home *** CD-ROM | disk | FTP | other *** search
- package mx.utils
- {
- import flash.utils.ByteArray;
-
- public class HexDecoder
- {
- private var _output:ByteArray;
-
- private var _work:Array = [0,0];
-
- public function HexDecoder()
- {
- super();
- _output = new ByteArray();
- }
-
- public function flush() : ByteArray
- {
- return drain();
- }
-
- public function drain() : ByteArray
- {
- var _loc1_:ByteArray = _output;
- _output = new ByteArray();
- _loc1_.position = 0;
- return _loc1_;
- }
-
- public function digit(param1:String) : int
- {
- switch(param1)
- {
- case "A":
- case "a":
- return 10;
- case "B":
- case "b":
- return 11;
- case "C":
- case "c":
- return 12;
- case "D":
- case "d":
- return 13;
- case "E":
- case "e":
- return 14;
- case "F":
- case "f":
- return 15;
- default:
- return new Number(param1);
- }
- }
-
- public function decode(param1:String) : void
- {
- var _loc2_:int = 0;
- while(_loc2_ < param1.length)
- {
- _work[0] = digit(param1.charAt(_loc2_));
- _loc2_++;
- _work[1] = digit(param1.charAt(_loc2_));
- _output.writeByte((_work[0] << 4 | _work[1]) & 0xFF);
- _loc2_++;
- }
- }
- }
- }
-
-