Created
February 14, 2017 19:53
-
-
Save TheNoim/6cdd422ddf2ff30b54de9fe0397bb153 to your computer and use it in GitHub Desktop.
DSB encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pako = require('pako'); | |
var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
function btoa(b) { | |
var c, d, e = ""; | |
for (c = 0, | |
d = b.length; d > c; c += 3) { | |
var f = 255 & b.charCodeAt(c) | |
, g = 255 & b.charCodeAt(c + 1) | |
, h = 255 & b.charCodeAt(c + 2) | |
, i = f >> 2 | |
, j = (3 & f) << 4 | g >> 4 | |
, k = d > c + 1 ? (15 & g) << 2 | h >> 6 : 64 | |
, l = d > c + 2 ? 63 & h : 64; | |
e += a.charAt(i) + a.charAt(j) + a.charAt(k) + a.charAt(l) | |
} | |
return e | |
} | |
function b(a) { | |
var b = pako.deflate(JSON.stringify(a), { | |
to: "string", | |
gzip: !0 | |
}); | |
return b = btoa(b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment