mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-16 08:58:30 +01:00
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
/**
|
|
* @author n1474335 [n1474335@gmail.com]
|
|
* @copyright Crown Copyright 2016
|
|
* @license Apache-2.0
|
|
*/
|
|
|
|
import Operation from "../Operation.mjs";
|
|
import gunzip from "zlibjs/bin/gunzip.min.js";
|
|
|
|
const Zlib = gunzip.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.infoURL = "https://wikipedia.org/wiki/Gzip";
|
|
this.inputType = "ArrayBuffer";
|
|
this.outputType = "ArrayBuffer";
|
|
this.args = [];
|
|
this.checks = {
|
|
input: {
|
|
regex: [
|
|
{
|
|
match: "^\\x1f\\x8b\\x08",
|
|
flags: "",
|
|
args: []
|
|
}
|
|
]
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @param {ArrayBuffer} input
|
|
* @param {Object[]} args
|
|
* @returns {File}
|
|
*/
|
|
run(input, args) {
|
|
const gzipObj = new Zlib.Gunzip(new Uint8Array(input));
|
|
return new Uint8Array(gzipObj.decompress()).buffer;
|
|
}
|
|
|
|
}
|
|
|
|
export default Gunzip;
|