mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
ESM: Added Zlib ops and created a Zlib library.
This commit is contained in:
parent
fbb3a02315
commit
083d2d1cc4
16 changed files with 913 additions and 350 deletions
46
src/core/operations/Gunzip.mjs
Normal file
46
src/core/operations/Gunzip.mjs
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import Utils from "../Utils";
|
||||
import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min";
|
||||
|
||||
const Zlib = zlibAndGzip.Zlib;
|
||||
|
||||
/**
|
||||
* Gunzip operation
|
||||
*/
|
||||
class Gunzip extends Operation {
|
||||
|
||||
/**
|
||||
* Gunzip constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Gunzip";
|
||||
this.module = "Compression";
|
||||
this.description = "Decompresses data which has been compressed using the deflate algorithm with gzip headers.";
|
||||
this.inputType = "byteArray";
|
||||
this.outputType = "byteArray";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
run(input, args) {
|
||||
// Deal with character encoding issues
|
||||
input = Utils.strToByteArray(Utils.byteArrayToUtf8(input));
|
||||
const gunzip = new Zlib.Gunzip(input);
|
||||
return Array.prototype.slice.call(gunzip.decompress());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Gunzip;
|
Loading…
Add table
Add a link
Reference in a new issue