UNPKG

cyberchef

Version:

The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.

56 lines (48 loc) 1.65 kB
/** * @author n1474335 [n1474335@gmail.com] * @copyright Crown Copyright 2016 * @license Apache-2.0 */ import r from "jsrsasign"; import Operation from "../Operation.mjs"; /** * Parse ASN.1 hex string operation */ class ParseASN1HexString extends Operation { /** * ParseASN1HexString constructor */ constructor() { super(); this.name = "Parse ASN.1 hex string"; this.module = "PublicKey"; this.description = "Abstract Syntax Notation One (ASN.1) is a standard and notation that describes rules and structures for representing, encoding, transmitting, and decoding data in telecommunications and computer networking.<br><br>This operation parses arbitrary ASN.1 data (encoded as an hex string: use the 'To Hex' operation if necessary) and presents the resulting tree."; this.infoURL = "https://wikipedia.org/wiki/Abstract_Syntax_Notation_One"; this.inputType = "string"; this.outputType = "string"; this.args = [ { "name": "Starting index", "type": "number", "value": 0 }, { "name": "Truncate octet strings longer than", "type": "number", "value": 32 } ]; } /** * @param {string} input * @param {Object[]} args * @returns {string} */ run(input, args) { const [index, truncateLen] = args; return r.ASN1HEX.dump(input.replace(/\s/g, "").toLowerCase(), { "ommit_long_octet": truncateLen }, index); } } export default ParseASN1HexString;