CyberChef/src/core/operations/CBORDecode.mjs

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-03-28 21:13:49 +01:00
/**
* @author Danh4 [dan.h4@ncsc.gov.uk]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
import Cbor from "cbor";
/**
* CBOR Decode operation
*/
class CBORDecode extends Operation {
/**
* CBORDecode constructor
*/
constructor() {
super();
this.name = "CBOR Decode";
2021-03-26 15:07:02 +01:00
this.module = "Serialise";
this.description = "Concise Binary Object Representation (CBOR) is a binary data serialization format loosely based on JSON. Like JSON it allows the transmission of data objects that contain namevalue pairs, but in a more concise manner. This increases processing and transfer speeds at the cost of human readability. It is defined in IETF RFC 8949.";
this.infoURL = "https://wikipedia.org/wiki/CBOR";
2020-03-28 21:13:49 +01:00
this.inputType = "ArrayBuffer";
this.outputType = "JSON";
2021-03-26 15:07:02 +01:00
this.args = [];
2020-03-28 21:13:49 +01:00
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {JSON}
*/
run(input, args) {
return Cbor.decodeFirstSync(Buffer.from(input).toString("hex"));
}
}
export default CBORDecode;