vendredi 27 janvier 2017

Convert an API KEY to string of numbers and reverse in ActionScripts3

We need to convert some API KEYs to string numbers and convert that numbers to original string.

Sample API KEY: "ZfIgG9LliwY4cDw4Rqso0m7SEQZovI"

We converted it with our algorithm

var encode_array:Array = "ZfIgG9LliwY4cDw4Rqso0m7SEQZovI".split("");
var encode_string:String;
var count1:int = encode_array.length; var i1:int;
for (i1 = 0; i1 < count1; i1++) 
{ 

    switch(encode_array[i1]) 
   { 
    case "*": 
        encode_string += *;
        break; 
    ...
   }

Converted API KEY:"364219431799224845593594391459942853555190499729152736515819"

Each 2 numbers in this string are related to 1 chracter in API KEY.(Sample: "36" > "Z")

My problem is second part to reverse this (convert each 2 number to defined character), How to possible separate every 2 numbers in this string and save them in an array? I think it possible with RegExp in ActionScripts, but i don't know how.

Aucun commentaire:

Enregistrer un commentaire