Created
March 23, 2019 02:18
-
-
Save dungwinux/fe37ac8ba5dd6b59c1fc8ea08911c6e2 to your computer and use it in GitHub Desktop.
Javascript version of Themis config uncompresser
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
const zlib = require("zlib"); | |
const fs = require("fs"); | |
function decode(s) { | |
let dec = zlib.inflateSync(s); | |
let res = dec.toString("utf8"); | |
return res; | |
} | |
function encode(s) { | |
let enc = zlib.deflateSync(s); | |
return enc; | |
} | |
if (require.main === module) { | |
const fn = process.argv[2]; | |
const s = fs.readFileSync(fn); | |
if (fn.substr(-4) === ".xml") { | |
const out = encode(s); | |
fs.writeFileSync(fn.substr(0, fn.length - 4), out); | |
} else { | |
const out = decode(s); | |
fs.writeFileSync(fn + ".xml", out); | |
} | |
} | |
module.exports = { decode, encode }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment