mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
ESM: Ported PublicKey operations
This commit is contained in:
parent
709630f39b
commit
049656ec6b
7 changed files with 518 additions and 0 deletions
46
src/core/operations/HexToPEM.mjs
Normal file
46
src/core/operations/HexToPEM.mjs
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import r from "jsrsasign";
|
||||
import Operation from "../Operation";
|
||||
|
||||
/**
|
||||
* Hex to PEM operation
|
||||
*/
|
||||
class HexToPEM extends Operation {
|
||||
|
||||
/**
|
||||
* HexToPEM constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Hex to PEM";
|
||||
this.module = "PublicKey";
|
||||
this.description = "Converts a hexadecimal DER (Distinguished Encoding Rules) string into PEM (Privacy Enhanced Mail) format.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Header string",
|
||||
"type": "string",
|
||||
"value": "CERTIFICATE"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
return r.KJUR.asn1.ASN1Util.getPEMStringFromHex(input.replace(/\s/g, ""), args[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default HexToPEM;
|
Loading…
Add table
Add a link
Reference in a new issue