1

I need a proven example to show how its possible to encrypt a string in AS3 and decrypt it in Ruby and vice versa ?, I found articles in PHP, but, I didn't find any in Ruby.

Can some one help by providing an example or some blog ?

simo
  • 23,342
  • 38
  • 121
  • 218

1 Answers1

1

Why don't you create your own algorithm to encrypt your strings?

You can create a variation of ROT13, and use a similar code in both languages. So simple.

ROT 13 is something like this in AS3:

function calculate(src : String) : String {
    var charsMap : String = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMabcdefghijklmnopqrstuvwxyzabcdefghijklm";

    var calculated : String = new String("");
    for (var i : Number = 0; i < src.length ; i++) {
        var character : String = src.charAt(i);
        var pos : Number = charsMap.indexOf(character);
        if (pos > -1) character = charsMap.charAt(pos + 13);
        calculated += character;
    }
    return calculated;
}

What I recommend to you is make a variation, shuffling your string in some non-random pattern, and un-shuffle in your Ruby code.

Marcelo Assis
  • 5,136
  • 3
  • 33
  • 54
  • I don't think ROT13 is secure enough, I am building a licensing solution for my software – simo Sep 03 '12 at 20:18
  • I'm **sure** that ROT13 isn't secure(as any other popular kind of encoding/decoding, like Base64), that's why I wrote twice in my post to make a **variation** of that. I spoke of it just to start an idea about shuffling chars in a custom way. – Marcelo Assis Sep 03 '12 at 21:26
  • Thanks Marcelo, I appreciate you support – simo Sep 04 '12 at 04:05