A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: help decoding text

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    3

    help decoding text

    Hi, can anyone help me fix this? Been struggling for a while now. Any ideas?

    Code:
    var secretMessage:String="REDACTED";
    var key:String="The way of the Actionscript warrior";
    var messageText:TextField;
    
    
    function createMessageTxtField():void{
      messageText = new TextField();
      messageText.width = 15;
      
      messageText.multiline = false;
      messageText.wordWrap = false;
     
    }
    
    function decodeMessage(source : String, key : String):void {
     var result : Array = new Array();
     var kl:int=key.length;
     var fn:Function=String.fromCharCode;
    
     var i:int=0;
     var n : int = source.length;
    
     for (;i < n; ++i) {;
      result.push(fn(source.charCodeAt(i) ^ key.charCodeAt(i %kl)));
     }
    
     messageText.htmlText=result;
     
    }
    Last edited by 5TonsOfFlax; 03-31-2010 at 08:43 AM. Reason: remove trojan payload.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    If you mean to fix the text issues with unusual characters you need to use unescape.
    var secretMessage:String=unescape(string or variable here);
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    I just unescaped the above code...

    A virus alert stopped it.
    Search first, asked questions later.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Thanks Ralgoth. I sanitized the program a bit and looked at the decoded message. It's not plaintext in any readable language.

    tom-tmp, explain yourself. What is the decoded message supposed to be?

  5. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Unfortunately i don't know what the decoded message is meant to be. That's the problem. But i know it's supposed to be in plain english.

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I have attached a screenshot of the message. If you got a virus alert, then we need an explanation from the user. I haven't thought that somebody may post malicious text here.
    Attached Images Attached Images
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    The message as decoded by the algorithm originally posted with the unescape fix starts with "<p><u> Flash MW", then has a bunch of non-printable characters that look suspicious to me.

    Where'd you get the secret message, and the decoding algorithm?

  8. #8
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Hmm, i don't think that's the decoded text. I can assure you there's nothing malicious here.

  9. #9
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    so you don't know the message or what it's supposed to be. My only assumption is that you shouldn't be meddling with it.

    If you need a way to encode/decode your own messages, then here's a functional iteration of the code you supplied...

    Actionscript Code:
    var msg:String = "Shhhh, don't tell anyone!";
    var key:String = "it's a secret!";

    var encoded:String = encode(msg, key);

    trace(encoded);
    // output: %3A%1CO%1BHM%00%17%0A%0DU%11TU%0C%18KSA%0FY%1C%0B%06S

    trace(decode(encoded, key));
    // output: Shhhh, don't tell anyone!

    trace(decode(encoded, 'not the right key'));
    // output: Ts;;<%e7xd2y ug}2=.{yhccs

    function encode(source:String, key:String):String
    {
        var result:String = '';
        for (var i:uint=0; i<source.length; i++) {;
            result += String.fromCharCode(source.charCodeAt(i)^key.charCodeAt(i%key.length));
        }
       
        return escape(result);
    }

    function decode(source:String, key:String):String
    {
        source = unescape(source);
       
        var result:String = '';
        for (var i:uint=0; i<source.length; i++) {;
            result += String.fromCharCode(source.charCodeAt(i)^key.charCodeAt(i%key.length));
        }
       
        return result;
    }
    Search first, asked questions later.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center