mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
ESM: Ported Punycode, HTTP and PRNG operations
This commit is contained in:
parent
0d1e5311dc
commit
c29ea53405
6 changed files with 427 additions and 0 deletions
52
src/core/operations/FromPunycode.mjs
Normal file
52
src/core/operations/FromPunycode.mjs
Normal file
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import punycode from "punycode";
|
||||
|
||||
/**
|
||||
* From Punycode operation
|
||||
*/
|
||||
class FromPunycode extends Operation {
|
||||
|
||||
/**
|
||||
* FromPunycode constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "From Punycode";
|
||||
this.module = "Encodings";
|
||||
this.description = "Punycode is a way to represent Unicode with the limited character subset of ASCII supported by the Domain Name System.<br><br>e.g. <code>mnchen-3ya</code> decodes to <code>m\xfcnchen</code>";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Internationalised domain name",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const idn = args[0];
|
||||
|
||||
if (idn) {
|
||||
return punycode.toUnicode(input);
|
||||
} else {
|
||||
return punycode.decode(input);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default FromPunycode;
|
Loading…
Add table
Add a link
Reference in a new issue