views:

15

answers:

1

Following is a php function for masking a string. Can somebody give me the actionscript equalent for this function.

public static function simple_encrypt($input) {
        $return = array();
        for($i = 0; $i < strlen($input); $i++){
            $ascii = ord(substr($input, $i, 1)) * 2;
            $return[] = base_convert($ascii, 10, 32);
        }
        return sprintf('RL%s', implode('', $return) ); // "RL" ensures it starts with a letter
}
+2  A: 
public static function simple_encrypt(input:String):String {
        var ret = [];
        var ascii:Number;
        for(var i:Number = 0; i < input.length; i++) {
            ascii = input.charCodeAt(i) * 2;
            ret.push(ascii.toString(32));
        }
        //I don't speak php, so I am assuming that 
        //RL doesn't have any syntactical meaning with sprintf
        return "RL" + ret.join(''); //joins everything to a single string.
}
Amarghosh
Thanks dude, this one is perfectly answering it.
Wind Chimez