Created
July 28, 2022 21:27
-
-
Save Shazambom/86f84b0db478d3a1b1a9992f298a1258 to your computer and use it in GitHub Desktop.
Decode a byte string in base64 and inflate it using zip
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
import pako from "pako"; | |
decode = async (base64) => { | |
let bin = window.atob(base64) | |
let bytes = new Uint8Array(bin.length) | |
for (let i = 0; i < bin.length; i++) { | |
bytes[i] = bin.charCodeAt(i); | |
} | |
let data = String.fromCharCode.apply(null, new Uint16Array(pako.inflate(bytes))); | |
return JSON.parse(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment