Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.utils.ByteArray;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.geom.Point;
- import com.hurlant.math.BigInteger;
- public class BitmapFunctions {
- private var Banner:habboBanner;
- private var pixels:ByteArray;
- private var decodeResult:String = "";
- private var xorResult:String = "";
- private var firstLength:int = 0;
- private var secondLength:int = 0;
- private var firstKey:String = "";
- private var secondKey:String = "";
- public function BitmapFunctions() {
- trace("Constructed bitmap decoding class");
- this.Banner = new habboBanner(0,0);
- this.pixels = this.Banner.getPixels(this.Banner.rect);
- this.decodeResult = this.decodeBitmap(this.pixels, this.Banner.width, 4, new Point(4, 39), new Point(80, 30));
- this.xorResult = this.xorTest(this.decodeResult, "secret");
- //6d14d6c1682bf00e7c61c584e5c4f5b3 << Token
- this.firstLength = this.xorResult.charCodeAt(0);
- this.secondLength = this.xorResult.charCodeAt((this.firstLength + 1));
- this.firstKey = this.xorResult.substr(1, this.firstLength);
- this.secondKey = this.xorResult.substr(this.firstLength + 2, this.secondLength);
- trace("First Length -> " + this.firstLength);
- trace("First Key -> " + this.firstKey);
- trace("");
- trace("Second Length -> " + this.secondLength);
- trace("Second Key -> " + this.secondKey);
- var first:BigInteger = new BigInteger();
- var second:BigInteger = new BigInteger();
- first.fromRadix(this.firstKey, 10);
- second.fromRadix(this.secondKey, 10);
- trace("Prime -> " + first.toString());
- trace();
- trace("Generator -> " + second.toString());
- }
- private function xor(pixelStr:String, token:String) : String {
- var pixelCode:uint = 0;
- var resultStr:String = "";
- var tokenIterate:int = 0;
- var pixelIterate:int = 0;
- while (pixelIterate < pixelStr.length) {
- pixelCode = pixelStr.charCodeAt(pixelIterate);
- resultStr = resultStr + String.fromCharCode(pixelCode ^ token.charCodeAt(tokenIterate));
- tokenIterate++;
- if (tokenIterate == token.length) {
- tokenIterate = 0;
- }
- pixelIterate++;
- }
- return resultStr;
- }
- private function xorTest(pixelStr:String, token:String) : String {
- var pixelCode:uint = 0;
- var resultStr:String = "";
- var tokenIterate:int = 0;
- for (var pixelIterate:int = 0; pixelIterate < pixelStr.length; pixelIterate++) {
- pixelCode = pixelStr.charCodeAt(pixelIterate);
- resultStr = resultStr + String.fromCharCode(pixelCode ^ token.charCodeAt(tokenIterate));
- tokenIterate++;
- if (tokenIterate == token.length) {
- tokenIterate = 0;
- }
- }
- return resultStr;
- }
- private function decodeBitmap(bitmap:ByteArray, bitmapWidth:int, aCount:int, pos1:Point, pos2:Point) : String {
- var pos1X:int = 0; // loc12
- var pos1Y:int = 0; // loc11
- var pixelPos:uint = 0; //loc13
- var rowStart:int = 0; //loc10
- var rowRemainder:uint = 0; //loc9
- var tRow:uint = 0; // loc14
- var uByte:uint = 0; // loc15
- var uByteMasked:uint = 0; // loc16
- var bitCount:uint = 0; // loc7
- var shiftBuffer:uint = 0; // loc8
- var resultBuffer:String = "";
- if (aCount == 4) {
- // Starting row will be 1
- rowStart = 1;
- }
- pos1Y = pos1.y;
- while (pos1Y < pos1.y + pos2.y) {
- pos1X = pos1.x;
- while (pos1X < pos1.x + pos2.x) {
- pixelPos = ((pos1Y + rowRemainder) * bitmapWidth + pos1X) * aCount;
- tRow = rowStart;
- while (tRow < aCount) {
- bitmap.position = pixelPos + tRow;
- uByte = bitmap.readUnsignedByte();
- uByteMasked = uByte & 1;
- shiftBuffer = shiftBuffer | uByteMasked << 7 - bitCount;
- if (bitCount == 7) {
- resultBuffer = resultBuffer + String.fromCharCode(shiftBuffer);
- shiftBuffer = 0;
- bitCount = 0;
- }
- else {
- bitCount = bitCount + 1;
- }
- tRow++;
- }
- if (pos1X % 2 == 0) {
- rowRemainder = rowRemainder + 1;
- }
- pos1X++;
- }
- rowRemainder = 0;
- pos1Y++;
- }
- return resultBuffer;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement