JSFiddle - React, Tailwind, and code Playground
JavaScript
var enc = '1010101011101100100010100011011111101010010110010100100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
console.log(enc);
var dec;
console.log(
dec =
// Encode
enc.match(/.{1,6}/g).map(function(chunk, idx, arr) {
return [Math.min(61, parseInt(chunk, 2)), (this.rem = Math.max(0, (parseInt(chunk, 2) + this.rem || 0) - 62)) > 0 && idx == arr.length - 1 ? this.rem : -1].map(function(n) {
return "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(n)
}).join('')
}).join('')
);
console.log("toto");
console.log(
// Decode
dec.split('').reverse().map(function(chr) {
var s = "000000" + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(chr).toString(2);
return s.substr(s.length - 6);
}).reverse().join('')
);