Search code examples
javascriptencode

What type of encoding used in example and how to do it with javascript?


I have an url with json file and parameters. They coded:

?.lk.:1x:3c:34:2t:32:37:2x:3a:2t:2q:39:3d:2t:36

I tried to google, but have not success. ((


Solution

  • You could split the values by colon ':', get the numerical values of hex values and build a string from this char codes.

    Voilà!

    Expensivebuyer
    

    var string = '.lk.:1x:3c:34:2t:32:37:2x:3a:2t:2q:39:3d:2t:36';
        values = string.split(':').map(v => parseInt(v, 36) || v);
    
    console.log(String.fromCharCode(...values));