mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
Add "{To,From} EBCDIC" operations
This adds operations + "To EBCDIC" + "From EBCDIC" This makes use of the npm codepage package but it is not installed as a dependency. Instead I used the `make.sh` script to export pages 37 and 500. To my knowledge there is no way currently to only import individual code pages from the npm package (hence the included script). If we were to import the package directly it increases the build size by 2.7MB.
This commit is contained in:
parent
31e5d785fe
commit
3c15bd9e29
5 changed files with 662 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
import cptable from "../lib/codepage.js";
|
||||
import Utils from "../Utils.js";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
|
@ -45,6 +46,52 @@ const CharEnc = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tlwr [toby@toby.codes]
|
||||
*
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
EBCDIC_CODEPAGES_MAPPING: {
|
||||
"IBM EBCDIC International": 500,
|
||||
"IBM EBCDIC US-Canada": 37,
|
||||
},
|
||||
|
||||
/**
|
||||
* To EBCDIC operation.
|
||||
*
|
||||
* @author tlwr [toby@toby.codes]
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
runToEBCDIC: function(input, args) {
|
||||
let pageNum = CharEnc.EBCDIC_CODEPAGES_MAPPING[args[0]];
|
||||
|
||||
let output = cptable.utils.encode(pageNum, input);
|
||||
|
||||
return Array.from(output);
|
||||
},
|
||||
|
||||
/**
|
||||
* From EBCDIC operation.
|
||||
*
|
||||
* @author tlwr [toby@toby.codes]
|
||||
*
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runFromEBCDIC: function(input, args) {
|
||||
let pageNum = CharEnc.EBCDIC_CODEPAGES_MAPPING[args[0]];
|
||||
|
||||
let output = cptable.utils.decode(pageNum, input);
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
export default CharEnc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue