',
- 'Compile time: ' + grunt.template.today("dd/mm/yyyy HH:MM:ss") + ' UTC');
- return grunt.template.process(content, template_options);
- }
- },
- src: "src/html/index.html",
- dest: "build/prod/cyberchef.htm"
- },
- static_dev: {
- files: [
- {
- expand: true,
- cwd: "src/static/",
- src: [
- "**/*",
- "**/.*",
- "!stats.txt"
- ],
- dest: "build/dev/"
- }
- ]
- },
- static_prod: {
- files: [
- {
- expand: true,
- cwd: "src/static/",
- src: [
- "**/*",
- "**/.*",
- "!stats.txt"
- ],
- dest: "build/prod/"
- }
- ]
- }
+ content = content.replace(
+ 'Download CyberChef
',
+ `Compile time: ${grunt.template.today('dd/mm/yyyy HH:MM:ss')} UTC`);
+ return grunt.template.process(content, template_options);
+ },
},
- uglify: {
- options: {
- preserveComments: function(node, comment) {
- if (comment.value.indexOf("* @license") === 0) return true;
- return false;
- },
- screwIE8: true,
- ASCIIOnly: true,
- beautify: {
- beautify: false,
- inline_script: true,
- ascii_only: true,
- screw_ie8: true
- },
- compress: {
- screw_ie8: true
- },
- banner: banner
- },
- prod: {
- src: "build/dev/scripts.js",
- dest: "build/prod/scripts.js"
- }
+ src: 'src/html/index.html',
+ dest: 'build/prod/cyberchef.htm',
+ },
+ static_dev: {
+ files: [
+ {
+ expand: true,
+ cwd: 'src/static/',
+ src: [
+ '**/*',
+ '**/.*',
+ '!stats.txt',
+ ],
+ dest: 'build/dev/',
+ },
+ ],
+ },
+ static_prod: {
+ files: [
+ {
+ expand: true,
+ cwd: 'src/static/',
+ src: [
+ '**/*',
+ '**/.*',
+ '!stats.txt',
+ ],
+ dest: 'build/prod/',
+ },
+ ],
+ },
+ },
+ uglify: {
+ options: {
+ preserveComments(node, comment) {
+ if (comment.value.indexOf('* @license') === 0) return true;
+ return false;
},
- cssmin: {
- prod: {
- src: "build/dev/styles.css",
- dest: "build/prod/styles.css"
- }
+ screwIE8: true,
+ ASCIIOnly: true,
+ beautify: {
+ beautify: false,
+ inline_script: true,
+ ascii_only: true,
+ screw_ie8: true,
},
- htmlmin: {
- prod: {
- options: {
- removeComments: true,
- collapseWhitespace: true,
- minifyJS: true,
- minifyCSS: true
- },
- src: "build/prod/index.html",
- dest: "build/prod/index.html"
- },
- inline: {
- options: {
- removeComments: true,
- collapseWhitespace: true,
- minifyJS: false,
- minifyCSS: false
- },
- src: "build/prod/cyberchef.htm",
- dest: "build/prod/cyberchef.htm"
- }
+ compress: {
+ screw_ie8: true,
},
- inline: {
- options: {
- tag: "",
- inlineTagAttributes: {
- js: "type='application/javascript'",
- css: "type='text/css'"
- }
- },
- prod: {
- src: "build/prod/cyberchef.htm",
- dest: "build/prod/cyberchef.htm"
- }
+ banner,
+ },
+ prod: {
+ src: 'build/dev/scripts.js',
+ dest: 'build/prod/scripts.js',
+ },
+ },
+ cssmin: {
+ prod: {
+ src: 'build/dev/styles.css',
+ dest: 'build/prod/styles.css',
+ },
+ },
+ htmlmin: {
+ prod: {
+ options: {
+ removeComments: true,
+ collapseWhitespace: true,
+ minifyJS: true,
+ minifyCSS: true,
},
- chmod: {
- build: {
- options: {
- mode: "755",
- },
- src: ["build/**/*", "build/**/.htaccess", "build/"]
- },
- docs: {
- options: {
- mode: "755",
- },
- src: ["docs/**/*", "docs/"]
- }
+ src: 'build/prod/index.html',
+ dest: 'build/prod/index.html',
+ },
+ inline: {
+ options: {
+ removeComments: true,
+ collapseWhitespace: true,
+ minifyJS: false,
+ minifyCSS: false,
},
- exec: {
- repo_size: {
- command: [
- "git ls-files | wc -l | xargs printf '\n%b\ttracked files\n'",
- "du -hs | egrep -o '^[^\t]*' | xargs printf '%b\trepository size\n'"
- ].join(";"),
- stderr: false
- },
- stats: {
- command: "rm src/static/stats.txt;" +
+ src: 'build/prod/cyberchef.htm',
+ dest: 'build/prod/cyberchef.htm',
+ },
+ },
+ inline: {
+ options: {
+ tag: '',
+ inlineTagAttributes: {
+ js: "type='application/javascript'",
+ css: "type='text/css'",
+ },
+ },
+ prod: {
+ src: 'build/prod/cyberchef.htm',
+ dest: 'build/prod/cyberchef.htm',
+ },
+ },
+ chmod: {
+ build: {
+ options: {
+ mode: '755',
+ },
+ src: ['build/**/*', 'build/**/.htaccess', 'build/'],
+ },
+ docs: {
+ options: {
+ mode: '755',
+ },
+ src: ['docs/**/*', 'docs/'],
+ },
+ },
+ exec: {
+ repo_size: {
+ command: [
+ "git ls-files | wc -l | xargs printf '\n%b\ttracked files\n'",
+ "du -hs | egrep -o '^[^\t]*' | xargs printf '%b\trepository size\n'",
+ ].join(';'),
+ stderr: false,
+ },
+ stats: {
+ command: `rm src/static/stats.txt;${
[
- "ls src/ -R1 | grep '^$' -v | grep ':$' -v | wc -l | xargs printf '%b\tsource files\n'",
- "find src/ -regex '.*\..*' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
- "du -hs src/ | pcregrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
+ "ls src/ -R1 | grep '^$' -v | grep ':$' -v | wc -l | xargs printf '%b\tsource files\n'",
+ "find src/ -regex '.*\..*' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
+ "du -hs src/ | pcregrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
- "ls src/js/ -R1 | grep '\.js$' | wc -l | xargs printf '\n%b\tJavaScript source files\n'",
- "find src/js/ -regex '.*\.js' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
- "find src/js/ -regex '.*\.js' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
+ "ls src/js/ -R1 | grep '\.js$' | wc -l | xargs printf '\n%b\tJavaScript source files\n'",
+ "find src/js/ -regex '.*\.js' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
+ "find src/js/ -regex '.*\.js' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
- "find src/js/ -regex '.*/lib/.*\.js' -print | wc -l | xargs printf '\n%b\tthird party JavaScript source files\n'",
- "find src/js/ -regex '.*/lib/.*\.js' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
- "find src/js/ -regex '.*/lib/.*\.js' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
+ "find src/js/ -regex '.*/lib/.*\.js' -print | wc -l | xargs printf '\n%b\tthird party JavaScript source files\n'",
+ "find src/js/ -regex '.*/lib/.*\.js' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
+ "find src/js/ -regex '.*/lib/.*\.js' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
- "find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -print | wc -l | xargs printf '\n%b\tfirst party JavaScript source files\n'",
- "find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
- "find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
+ "find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -print | wc -l | xargs printf '\n%b\tfirst party JavaScript source files\n'",
+ "find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
+ "find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
- "du build/dev/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '\n%b\tuncompressed JavaScript size\n'",
- "du build/prod/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '%b\tcompressed JavaScript size\n'",
-
- "grep -E '^\\s+name: ' src/js/config/Categories.js | wc -l | xargs printf '\n%b\tcategories\n'",
- "grep -E '^\\s+\"[A-Za-z0-9 \\-]+\": {' src/js/config/OperationConfig.js | wc -l | xargs printf '%b\toperations\n'",
-
- ].join(" >> src/static/stats.txt;") + " >> src/static/stats.txt;",
- stderr: false
- },
- display_stats: {
- command: "cat src/static/stats.txt"
- },
- clean_git: {
- command: "git gc --prune=now --aggressive"
- },
- },
- watch: {
- css: {
- files: "src/css/**/*.css",
- tasks: ["concat:css", "chmod:build"]
- },
- js: {
- files: "src/js/**/*.js",
- tasks: ["concat:js_all", "chmod:build"]
- },
- html: {
- files: "src/html/**/*.html",
- tasks: ["copy:html_dev", "chmod:build"]
- },
- static: {
- files: ["src/static/**/*", "src/static/**/.*"],
- tasks: ["copy:static_dev", "chmod:build"]
- },
- grunt: {
- files: "Gruntfile.js",
- tasks: ["clean:dev", "concat:css", "concat:js_all", "copy:html_dev", "copy:static_dev", "chmod:build"]
- }
- },
- });
+ "du build/dev/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '\n%b\tuncompressed JavaScript size\n'",
+ "du build/prod/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '%b\tcompressed JavaScript size\n'",
+ "grep -E '^\\s+name: ' src/js/config/Categories.js | wc -l | xargs printf '\n%b\tcategories\n'",
+ "grep -E '^\\s+\"[A-Za-z0-9 \\-]+\": {' src/js/config/OperationConfig.js | wc -l | xargs printf '%b\toperations\n'",
+
+ ].join(' >> src/static/stats.txt;')} >> src/static/stats.txt;`,
+ stderr: false,
+ },
+ display_stats: {
+ command: 'cat src/static/stats.txt',
+ },
+ clean_git: {
+ command: 'git gc --prune=now --aggressive',
+ },
+ },
+ watch: {
+ css: {
+ files: 'src/css/**/*.css',
+ tasks: ['concat:css', 'chmod:build'],
+ },
+ js: {
+ files: 'src/js/**/*.js',
+ tasks: ['concat:js_all', 'chmod:build'],
+ },
+ html: {
+ files: 'src/html/**/*.html',
+ tasks: ['copy:html_dev', 'chmod:build'],
+ },
+ static: {
+ files: ['src/static/**/*', 'src/static/**/.*'],
+ tasks: ['copy:static_dev', 'chmod:build'],
+ },
+ grunt: {
+ files: 'Gruntfile.js',
+ tasks: ['clean:dev', 'concat:css', 'concat:js_all', 'copy:html_dev', 'copy:static_dev', 'chmod:build'],
+ },
+ },
+ });
};
diff --git a/src/js/config/Categories.js b/src/js/config/Categories.js
index 02c2b1f5..02305f80 100755
--- a/src/js/config/Categories.js
+++ b/src/js/config/Categories.js
@@ -17,250 +17,250 @@
* @constant
* @type {CatConf[]}
*/
-var Categories = [
- {
- name: "Favourites",
- ops: []
- },
- {
- name: "Data format",
- ops: [
- "To Hexdump",
- "From Hexdump",
- "To Hex",
- "From Hex",
- "To Charcode",
- "From Charcode",
- "To Decimal",
- "From Decimal",
- "To Binary",
- "From Binary",
- "To Base64",
- "From Base64",
- "Show Base64 offsets",
- "To Base32",
- "From Base32",
- "To Base",
- "From Base",
- "To HTML Entity",
- "From HTML Entity",
- "URL Encode",
- "URL Decode",
- "Unescape Unicode Characters",
- "To Quoted Printable",
- "From Quoted Printable",
- "To Punycode",
- "From Punycode",
- "To Hex Content",
- "From Hex Content",
- "PEM to Hex",
- "Hex to PEM",
- "Parse ASN.1 hex string",
- "Change IP format",
- "Text encoding",
- "Swap endianness",
- ]
- },
- {
- name: "Encryption / Encoding",
- ops: [
- "AES Encrypt",
- "AES Decrypt",
- "Blowfish Encrypt",
- "Blowfish Decrypt",
- "DES Encrypt",
- "DES Decrypt",
- "Triple DES Encrypt",
- "Triple DES Decrypt",
- "Rabbit Encrypt",
- "Rabbit Decrypt",
- "RC4",
- "RC4 Drop",
- "ROT13",
- "XOR",
- "XOR Brute Force",
- "Derive PBKDF2 key",
- "Derive EVP key",
- ]
- },
- {
- name: "Public Key",
- ops: [
- "Parse X.509 certificate",
- "Parse ASN.1 hex string",
- "PEM to Hex",
- "Hex to PEM",
- "Hex to Object Identifier",
- "Object Identifier to Hex",
- ]
- },
- {
- name: "Logical operations",
- ops: [
- "XOR",
- "XOR Brute Force",
- "OR",
- "NOT",
- "AND",
- "ADD",
- "SUB",
- "Rotate left",
- "Rotate right",
- "ROT13",
- ]
- },
- {
- name: "Networking",
- ops: [
- "Strip HTTP headers",
- "Parse User Agent",
- "Parse IP range",
- "Parse IPv6 address",
- "Parse URI",
- "URL Encode",
- "URL Decode",
- "Format MAC addresses",
- "Change IP format",
- "Group IP addresses",
- ]
- },
- {
- name: "Language",
- ops: [
- "Text encoding",
- "Unescape Unicode Characters",
- ]
- },
- {
- name: "Utils",
- ops: [
- "Diff",
- "Remove whitespace",
- "Remove null bytes",
- "To Upper case",
- "To Lower case",
- "Add line numbers",
- "Remove line numbers",
- "Reverse",
- "Sort",
- "Unique",
- "Split",
- "Count occurrences",
- "Expand alphabet range",
- "Parse escaped string",
- "Drop bytes",
- "Take bytes",
- "Pad lines",
- "Find / Replace",
- "Regular expression",
- "Offset checker",
- "Convert distance",
- "Convert area",
- "Convert mass",
- "Convert speed",
- "Convert data units",
- "Parse UNIX file permissions",
- "Swap endianness",
- "Parse colour code",
- ]
- },
- {
- name: "Date / Time",
- ops: [
- "Parse DateTime",
- "Translate DateTime Format",
- "From UNIX Timestamp",
- "To UNIX Timestamp",
- "Extract dates",
- ]
- },
- {
- name: "Extractors",
- ops: [
- "Strings",
- "Extract IP addresses",
- "Extract email addresses",
- "Extract MAC addresses",
- "Extract URLs",
- "Extract domains",
- "Extract file paths",
- "Extract dates",
- "Regular expression",
- ]
- },
- {
- name: "Compression",
- ops: [
- "Raw Deflate",
- "Raw Inflate",
- "Zlib Deflate",
- "Zlib Inflate",
- "Gzip",
- "Gunzip",
- "Zip",
- "Unzip",
- "Bzip2 Decompress",
- ]
- },
- {
- name: "Hashing",
- ops: [
- "Analyse hash",
- "Generate all hashes",
- "MD5",
- "SHA1",
- "SHA224",
- "SHA256",
- "SHA384",
- "SHA512",
- "SHA3",
- "RIPEMD-160",
- "HMAC",
- "Fletcher-16 Checksum",
- "Adler-32 Checksum",
- "CRC-32 Checksum",
- "TCP/IP Checksum",
- ]
- },
- {
- name: "Code tidy",
- ops: [
- "Syntax highlighter",
- "Generic Code Beautify",
- "JavaScript Parser",
- "JavaScript Beautify",
- "JavaScript Minify",
- "JSON Beautify",
- "JSON Minify",
- "XML Beautify",
- "XML Minify",
- "SQL Beautify",
- "SQL Minify",
- "CSS Beautify",
- "CSS Minify",
- "Strip HTML tags",
- "Diff",
- ]
- },
- {
- name: "Other",
- ops: [
- "Entropy",
- "Frequency distribution",
- "Detect File Type",
- "Scan for Embedded Files",
- "Generate UUID",
- "Numberwang",
- ]
- },
- {
- name: "Flow control",
- ops: [
- "Fork",
- "Merge",
- "Jump",
- "Conditional Jump",
- "Return",
- ]
- },
+const Categories = [
+ {
+ name: 'Favourites',
+ ops: [],
+ },
+ {
+ name: 'Data format',
+ ops: [
+ 'To Hexdump',
+ 'From Hexdump',
+ 'To Hex',
+ 'From Hex',
+ 'To Charcode',
+ 'From Charcode',
+ 'To Decimal',
+ 'From Decimal',
+ 'To Binary',
+ 'From Binary',
+ 'To Base64',
+ 'From Base64',
+ 'Show Base64 offsets',
+ 'To Base32',
+ 'From Base32',
+ 'To Base',
+ 'From Base',
+ 'To HTML Entity',
+ 'From HTML Entity',
+ 'URL Encode',
+ 'URL Decode',
+ 'Unescape Unicode Characters',
+ 'To Quoted Printable',
+ 'From Quoted Printable',
+ 'To Punycode',
+ 'From Punycode',
+ 'To Hex Content',
+ 'From Hex Content',
+ 'PEM to Hex',
+ 'Hex to PEM',
+ 'Parse ASN.1 hex string',
+ 'Change IP format',
+ 'Text encoding',
+ 'Swap endianness',
+ ],
+ },
+ {
+ name: 'Encryption / Encoding',
+ ops: [
+ 'AES Encrypt',
+ 'AES Decrypt',
+ 'Blowfish Encrypt',
+ 'Blowfish Decrypt',
+ 'DES Encrypt',
+ 'DES Decrypt',
+ 'Triple DES Encrypt',
+ 'Triple DES Decrypt',
+ 'Rabbit Encrypt',
+ 'Rabbit Decrypt',
+ 'RC4',
+ 'RC4 Drop',
+ 'ROT13',
+ 'XOR',
+ 'XOR Brute Force',
+ 'Derive PBKDF2 key',
+ 'Derive EVP key',
+ ],
+ },
+ {
+ name: 'Public Key',
+ ops: [
+ 'Parse X.509 certificate',
+ 'Parse ASN.1 hex string',
+ 'PEM to Hex',
+ 'Hex to PEM',
+ 'Hex to Object Identifier',
+ 'Object Identifier to Hex',
+ ],
+ },
+ {
+ name: 'Logical operations',
+ ops: [
+ 'XOR',
+ 'XOR Brute Force',
+ 'OR',
+ 'NOT',
+ 'AND',
+ 'ADD',
+ 'SUB',
+ 'Rotate left',
+ 'Rotate right',
+ 'ROT13',
+ ],
+ },
+ {
+ name: 'Networking',
+ ops: [
+ 'Strip HTTP headers',
+ 'Parse User Agent',
+ 'Parse IP range',
+ 'Parse IPv6 address',
+ 'Parse URI',
+ 'URL Encode',
+ 'URL Decode',
+ 'Format MAC addresses',
+ 'Change IP format',
+ 'Group IP addresses',
+ ],
+ },
+ {
+ name: 'Language',
+ ops: [
+ 'Text encoding',
+ 'Unescape Unicode Characters',
+ ],
+ },
+ {
+ name: 'Utils',
+ ops: [
+ 'Diff',
+ 'Remove whitespace',
+ 'Remove null bytes',
+ 'To Upper case',
+ 'To Lower case',
+ 'Add line numbers',
+ 'Remove line numbers',
+ 'Reverse',
+ 'Sort',
+ 'Unique',
+ 'Split',
+ 'Count occurrences',
+ 'Expand alphabet range',
+ 'Parse escaped string',
+ 'Drop bytes',
+ 'Take bytes',
+ 'Pad lines',
+ 'Find / Replace',
+ 'Regular expression',
+ 'Offset checker',
+ 'Convert distance',
+ 'Convert area',
+ 'Convert mass',
+ 'Convert speed',
+ 'Convert data units',
+ 'Parse UNIX file permissions',
+ 'Swap endianness',
+ 'Parse colour code',
+ ],
+ },
+ {
+ name: 'Date / Time',
+ ops: [
+ 'Parse DateTime',
+ 'Translate DateTime Format',
+ 'From UNIX Timestamp',
+ 'To UNIX Timestamp',
+ 'Extract dates',
+ ],
+ },
+ {
+ name: 'Extractors',
+ ops: [
+ 'Strings',
+ 'Extract IP addresses',
+ 'Extract email addresses',
+ 'Extract MAC addresses',
+ 'Extract URLs',
+ 'Extract domains',
+ 'Extract file paths',
+ 'Extract dates',
+ 'Regular expression',
+ ],
+ },
+ {
+ name: 'Compression',
+ ops: [
+ 'Raw Deflate',
+ 'Raw Inflate',
+ 'Zlib Deflate',
+ 'Zlib Inflate',
+ 'Gzip',
+ 'Gunzip',
+ 'Zip',
+ 'Unzip',
+ 'Bzip2 Decompress',
+ ],
+ },
+ {
+ name: 'Hashing',
+ ops: [
+ 'Analyse hash',
+ 'Generate all hashes',
+ 'MD5',
+ 'SHA1',
+ 'SHA224',
+ 'SHA256',
+ 'SHA384',
+ 'SHA512',
+ 'SHA3',
+ 'RIPEMD-160',
+ 'HMAC',
+ 'Fletcher-16 Checksum',
+ 'Adler-32 Checksum',
+ 'CRC-32 Checksum',
+ 'TCP/IP Checksum',
+ ],
+ },
+ {
+ name: 'Code tidy',
+ ops: [
+ 'Syntax highlighter',
+ 'Generic Code Beautify',
+ 'JavaScript Parser',
+ 'JavaScript Beautify',
+ 'JavaScript Minify',
+ 'JSON Beautify',
+ 'JSON Minify',
+ 'XML Beautify',
+ 'XML Minify',
+ 'SQL Beautify',
+ 'SQL Minify',
+ 'CSS Beautify',
+ 'CSS Minify',
+ 'Strip HTML tags',
+ 'Diff',
+ ],
+ },
+ {
+ name: 'Other',
+ ops: [
+ 'Entropy',
+ 'Frequency distribution',
+ 'Detect File Type',
+ 'Scan for Embedded Files',
+ 'Generate UUID',
+ 'Numberwang',
+ ],
+ },
+ {
+ name: 'Flow control',
+ ops: [
+ 'Fork',
+ 'Merge',
+ 'Jump',
+ 'Conditional Jump',
+ 'Return',
+ ],
+ },
];
diff --git a/src/js/config/OperationConfig.js b/src/js/config/OperationConfig.js
index f011a0b2..f8c74a9a 100755
--- a/src/js/config/OperationConfig.js
+++ b/src/js/config/OperationConfig.js
@@ -20,7 +20,7 @@
* @property {boolean} [flow_control] - True if the operation is for Flow Control
* @property {ArgConf[]} [args] - A list of configuration objects for the arguments
*/
-
+
/**
* Type definition for an ArgConf.
@@ -45,2742 +45,2742 @@
* @constant
* @type {Object.aGVsbG8= becomes hello",
- run: Base64.run_from,
- highlight: Base64.highlight_from,
- highlight_reverse: Base64.highlight_to,
- input_type: "string",
- output_type: "byte_array",
- args: [
- {
- name: "Alphabet",
- type: "editable_option",
- value: Base64.ALPHABET_OPTIONS
- },
- {
- name: "Remove non‑alphabet chars",
- type: "boolean",
- value: Base64.REMOVE_NON_ALPH_CHARS
- }
- ]
- },
- "To Base64": {
- description: "Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.hello becomes aGVsbG8=",
- run: Base64.run_to,
- highlight: Base64.highlight_to,
- highlight_reverse: Base64.highlight_from,
- input_type: "byte_array",
- output_type: "string",
- args: [
- {
- name: "Alphabet",
- type: "editable_option",
- value: Base64.ALPHABET_OPTIONS
- },
- ]
- },
- "From Base32": {
- description: "Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.",
- run: Base64.run_from_32,
- input_type: "string",
- output_type: "byte_array",
- args: [
- {
- name: "Alphabet",
- type: "binary_string",
- value: Base64.BASE32_ALPHABET
- },
- {
- name: "Remove non‑alphabet chars",
- type: "boolean",
- value: Base64.REMOVE_NON_ALPH_CHARS
- }
- ]
- },
- "To Base32": {
- description: "Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.",
- run: Base64.run_to_32,
- input_type: "byte_array",
- output_type: "string",
- args: [
- {
- name: "Alphabet",
- type: "binary_string",
- value: Base64.BASE32_ALPHABET
- }
- ]
- },
- "Show Base64 offsets": {
- description: "When a string is within a block of data and the whole block is Base64'd, the string itself could be represented in Base64 in three distinct ways depending on its offset within the block.fe023da5fe023da5",
- run: BitwiseOp.run_and,
- highlight: true,
- highlight_reverse: true,
- input_type: "byte_array",
- output_type: "byte_array",
- args: [
- {
- name: "Key",
- type: "toggle_string",
- value: "",
- toggle_values: BitwiseOp.KEY_FORMAT
- }
- ]
- },
- "OR": {
- description: "OR the input with the given key.fe023da5",
- run: BitwiseOp.run_or,
- highlight: true,
- highlight_reverse: true,
- input_type: "byte_array",
- output_type: "byte_array",
- args: [
- {
- name: "Key",
- type: "toggle_string",
- value: "",
- toggle_values: BitwiseOp.KEY_FORMAT
- }
- ]
- },
- "ADD": {
- description: "ADD the input with the given key (e.g. fe023da5), MOD 255",
- run: BitwiseOp.run_add,
- highlight: true,
- highlight_reverse: true,
- input_type: "byte_array",
- output_type: "byte_array",
- args: [
- {
- name: "Key",
- type: "toggle_string",
- value: "",
- toggle_values: BitwiseOp.KEY_FORMAT
- }
- ]
- },
- "SUB": {
- description: "SUB the input with the given key (e.g. fe023da5), MOD 255",
- run: BitwiseOp.run_sub,
- highlight: true,
- highlight_reverse: true,
- input_type: "byte_array",
- output_type: "byte_array",
- args: [
- {
- name: "Key",
- type: "toggle_string",
- value: "",
- toggle_values: BitwiseOp.KEY_FORMAT
- }
- ]
- },
- "From Hex": {
- description: "Converts a hexadecimal byte string back into a its raw value.ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a becomes the UTF-8 encoded string Γειά σου",
- run: ByteRepr.run_from_hex,
- highlight: ByteRepr.highlight_from,
- highlight_reverse: ByteRepr.highlight_to,
- input_type: "string",
- output_type: "byte_array",
- args: [
- {
- name: "Delimiter",
- type: "option",
- value: ByteRepr.HEX_DELIM_OPTIONS
- }
- ]
- },
- "To Hex": {
- description: "Converts the input string to hexadecimal bytes separated by the specified delimiter.Γειά σου becomes ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a",
- run: ByteRepr.run_to_hex,
- highlight: ByteRepr.highlight_to,
- highlight_reverse: ByteRepr.highlight_from,
- input_type: "byte_array",
- output_type: "string",
- args: [
- {
- name: "Delimiter",
- type: "option",
- value: ByteRepr.HEX_DELIM_OPTIONS
- }
- ]
- },
- "From Charcode": {
- description: "Converts unicode character codes back into text.0393 03b5 03b9 03ac 20 03c3 03bf 03c5 becomes Γειά σου",
- run: ByteRepr.run_from_charcode,
- highlight: ByteRepr.highlight_from,
- highlight_reverse: ByteRepr.highlight_to,
- input_type: "string",
- output_type: "byte_array",
- args: [
- {
- name: "Delimiter",
- type: "option",
- value: ByteRepr.DELIM_OPTIONS
- },
- {
- name: "Base",
- type: "number",
- value: ByteRepr.CHARCODE_BASE
- }
- ]
- },
- "To Charcode": {
- description: "Converts text to its unicode character code equivalent.Γειά σου becomes 0393 03b5 03b9 03ac 20 03c3 03bf 03c5",
- run: ByteRepr.run_to_charcode,
- highlight: ByteRepr.highlight_to,
- highlight_reverse: ByteRepr.highlight_from,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Delimiter",
- type: "option",
- value: ByteRepr.DELIM_OPTIONS
- },
- {
- name: "Base",
- type: "number",
- value: ByteRepr.CHARCODE_BASE
- }
- ]
- },
- "From Binary": {
- description: "Converts a binary string back into its raw form.01001000 01101001 becomes Hi",
- run: ByteRepr.run_from_binary,
- highlight: ByteRepr.highlight_from_binary,
- highlight_reverse: ByteRepr.highlight_to_binary,
- input_type: "string",
- output_type: "byte_array",
- args: [
- {
- name: "Delimiter",
- type: "option",
- value: ByteRepr.BIN_DELIM_OPTIONS
- }
- ]
- },
- "To Binary": {
- description: "Displays the input data as a binary string.Hi becomes 01001000 01101001",
- run: ByteRepr.run_to_binary,
- highlight: ByteRepr.highlight_to_binary,
- highlight_reverse: ByteRepr.highlight_from_binary,
- input_type: "byte_array",
- output_type: "string",
- args: [
- {
- name: "Delimiter",
- type: "option",
- value: ByteRepr.BIN_DELIM_OPTIONS
- }
- ]
- },
- "From Decimal": {
- description: "Converts the data from an ordinal integer array back into its raw form.72 101 108 108 111 becomes Hello",
- run: ByteRepr.run_from_decimal,
- input_type: "string",
- output_type: "byte_array",
- args: [
- {
- name: "Delimiter",
- type: "option",
- value: ByteRepr.DELIM_OPTIONS
- }
- ]
- },
- "To Decimal": {
- description: "Converts the input data to an ordinal integer array.Hello becomes 72 101 108 108 111",
- run: ByteRepr.run_to_decimal,
- input_type: "byte_array",
- output_type: "string",
- args: [
- {
- name: "Delimiter",
- type: "option",
- value: ByteRepr.DELIM_OPTIONS
- }
- ]
- },
- "From Hexdump": {
- description: "Attempts to convert a hexdump back into raw data. This operation supports many different hexdump variations, but probably not all. Make sure you verify that the data it gives you is correct before continuing analysis.",
- run: Hexdump.run_from,
- highlight: Hexdump.highlight_from,
- highlight_reverse: Hexdump.highlight_to,
- input_type: "string",
- output_type: "byte_array",
- args: []
- },
- "To Hexdump": {
- description: "Creates a hexdump of the input data, displaying both the hexademinal values of each byte and an ASCII representation alongside.",
- run: Hexdump.run_to,
- highlight: Hexdump.highlight_to,
- highlight_reverse: Hexdump.highlight_from,
- input_type: "byte_array",
- output_type: "string",
- args: [
- {
- name: "Width",
- type: "number",
- value: Hexdump.WIDTH
- },
- {
- name: "Upper case hex",
- type: "boolean",
- value: Hexdump.UPPER_CASE
- },
- {
- name: "Include final length",
- type: "boolean",
- value: Hexdump.INCLUDE_FINAL_LENGTH
- }
- ]
- },
- "From Base": {
- description: "Converts a number to decimal from a given numerical base.",
- run: Base.run_from,
- input_type: "string",
- output_type: "number",
- args: [
- {
- name: "Radix",
- type: "number",
- value: Base.DEFAULT_RADIX
- }
- ]
- },
- "To Base": {
- description: "Converts a decimal number to a given numerical base.",
- run: Base.run_to,
- input_type: "number",
- output_type: "string",
- args: [
- {
- name: "Radix",
- type: "number",
- value: Base.DEFAULT_RADIX
- }
- ]
- },
- "From HTML Entity": {
- description: "Converts HTML entities back to characters& becomes &", // tags required to stop the browser just printing &
- run: HTML.run_from_entity,
- input_type: "string",
- output_type: "string",
- args: []
- },
- "To HTML Entity": {
- description: "Converts characters to HTML entities& becomes &", // tags required to stop the browser just printing &
- run: HTML.run_to_entity,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Convert all characters",
- type: "boolean",
- value: HTML.CONVERT_ALL
- },
- {
- name: "Convert to",
- type: "option",
- value: HTML.CONVERT_OPTIONS
- }
- ]
- },
- "Strip HTML tags": {
- description: "Removes all HTML tags from the input.",
- run: HTML.run_strip_tags,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Remove indentation",
- type: "boolean",
- value: HTML.REMOVE_INDENTATION
- },
- {
- name: "Remove excess line breaks",
- type: "boolean",
- value: HTML.REMOVE_LINE_BREAKS
- }
- ]
- },
- "URL Decode": {
- description: "Converts URI/URL percent-encoded characters back to their raw values.%3d becomes =",
- run: URL_.run_from,
- input_type: "string",
- output_type: "string",
- args: []
- },
- "URL Encode": {
- description: "Encodes problematic characters into percent-encoding, a format supported by URIs/URLs.= becomes %3d",
- run: URL_.run_to,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Encode all special chars",
- type: "boolean",
- value: URL_.ENCODE_ALL
- }
- ]
- },
- "Parse URI": {
- description: "Pretty prints complicated Uniform Resource Identifier (URI) strings for ease of reading. Particularly useful for Uniform Resource Locators (URLs) with a lot of arguments.",
- run: URL_.run_parse,
- input_type: "string",
- output_type: "string",
- args: []
- },
- "Unescape Unicode Characters": {
- description: "Converts unicode-escaped character notation back into raw characters.\\u%uU+\\u03c3\\u03bf\\u03c5 becomes σου",
- run: Unicode.run_unescape,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Prefix",
- type: "option",
- value: Unicode.PREFIXES
- }
- ]
- },
- "From Quoted Printable": {
- description: "Converts QP-encoded text back to standard text.",
- run: QuotedPrintable.run_from,
- input_type: "string",
- output_type: "byte_array",
- args: []
- },
- "To Quoted Printable": {
- description: "Quoted-Printable, or QP encoding, is an encoding using printable ASCII characters (alphanumeric and the equals sign '=') to transmit 8-bit data over a 7-bit data path or, generally, over a medium which is not 8-bit clean. It is defined as a MIME content transfer encoding for use in e-mail.mnchen-3ya decodes to münchen",
- run: Punycode.run_to_unicode,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Internationalised domain name",
- type: "boolean",
- value: Punycode.IDN
- }
- ]
- },
- "To Punycode": {
- description: "Punycode is a way to represent Unicode with the limited character subset of ASCII supported by the Domain Name System.münchen encodes to mnchen-3ya",
- run: Punycode.run_to_ascii,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Internationalised domain name",
- type: "boolean",
- value: Punycode.IDN
- }
- ]
- },
- "From Hex Content": {
- description: "Translates hexadecimal bytes in text back to raw bytes.foo|3d|bar becomes foo=bar.",
- run: ByteRepr.run_from_hex_content,
- input_type: "string",
- output_type: "byte_array",
- args: []
- },
- "To Hex Content": {
- description: "Converts special characters in a string to hexadecimal.foo=bar becomes foo|3d|bar.",
- run: ByteRepr.run_to_hex_content,
- input_type: "byte_array",
- output_type: "string",
- args: [
- {
- name: "Convert",
- type: "option",
- value: ByteRepr.HEX_CONTENT_CONVERT_WHICH
- },
- {
- name: "Print spaces between bytes",
- type: "boolean",
- value: ByteRepr.HEX_CONTENT_SPACES_BETWEEN_BYTES
- },
- ]
- },
- "Change IP format": {
- description: "Convert an IP address from one format to another, e.g. 172.20.23.54 to ac141736",
- run: IP.run_change_ip_format,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Input format",
- type: "option",
- value: IP.IP_FORMAT_LIST
- },
- {
- name: "Output format",
- type: "option",
- value: IP.IP_FORMAT_LIST
- }
- ]
- },
- "Parse IP range": {
- description: "Given a CIDR range (e.g. 10.0.0.0/24) or a hyphenated range (e.g. 10.0.0.0 - 10.0.1.0), this operation provides network information and enumerates all IP addresses in the range.0x00) from the input.",
- run: Tidy.run_remove_nulls,
- input_type: "byte_array",
- output_type: "byte_array",
- args: []
- },
- "Drop bytes": {
- description: "Cuts the specified number of bytes out of the data.",
- run: Tidy.run_drop_bytes,
- input_type: "byte_array",
- output_type: "byte_array",
- args: [
- {
- name: "Start",
- type: "number",
- value: Tidy.DROP_START
- },
- {
- name: "Length",
- type: "number",
- value: Tidy.DROP_LENGTH
- },
- {
- name: "Apply to each line",
- type: "boolean",
- value: Tidy.APPLY_TO_EACH_LINE
- }
- ]
- },
- "Take bytes": {
- description: "Takes a slice of the specified number of bytes from the data.",
- run: Tidy.run_take_bytes,
- input_type: "byte_array",
- output_type: "byte_array",
- args: [
- {
- name: "Start",
- type: "number",
- value: Tidy.TAKE_START
- },
- {
- name: "Length",
- type: "number",
- value: Tidy.TAKE_LENGTH
- },
- {
- name: "Apply to each line",
- type: "boolean",
- value: Tidy.APPLY_TO_EACH_LINE
- }
- ]
- },
- "Pad lines": {
- description: "Add the specified number of the specified character to the beginning or end of each line",
- run: Tidy.run_pad,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Position",
- type: "option",
- value: Tidy.PAD_POSITION
- },
- {
- name: "Length",
- type: "number",
- value: Tidy.PAD_LENGTH
- },
- {
- name: "Character",
- type: "binary_short_string",
- value: Tidy.PAD_CHAR
- }
- ]
- },
- "Reverse": {
- description: "Reverses the input string.",
- run: SeqUtils.run_reverse,
- input_type: "byte_array",
- output_type: "byte_array",
- args: [
- {
- name: "By",
- type: "option",
- value: SeqUtils.REVERSE_BY
- }
- ]
- },
- "Sort": {
- description: "Alphabetically sorts strings separated by the specified delimiter.710.65.0.456, this will match 10.65.0.45 so always check the original input!",
- run: Extract.run_ip,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "IPv4",
- type: "boolean",
- value: Extract.INCLUDE_IPV4
- },
- {
- name: "IPv6",
- type: "boolean",
- value: Extract.INCLUDE_IPV6
- },
- {
- name: "Remove local IPv4 addresses",
- type: "boolean",
- value: Extract.REMOVE_LOCAL
- },
- {
- name: "Display total",
- type: "boolean",
- value: Extract.DISPLAY_TOTAL
- }
- ]
- },
- "Extract email addresses": {
- description: "Extracts all email addresses from the input.",
- run: Extract.run_email,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Display total",
- type: "boolean",
- value: Extract.DISPLAY_TOTAL
- }
- ]
- },
- "Extract MAC addresses": {
- description: "Extracts all Media Access Control (MAC) addresses from the input.",
- run: Extract.run_mac,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Display total",
- type: "boolean",
- value: Extract.DISPLAY_TOTAL
- }
- ]
- },
- "Extract URLs": {
- description: "Extracts Uniform Resource Locators (URLs) from the input. The protocol (http, ftp etc.) is required otherwise there will be far too many false positives.",
- run: Extract.run_urls,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Display total",
- type: "boolean",
- value: Extract.DISPLAY_TOTAL
- }
- ]
- },
- "Extract domains": {
- description: "Extracts domain names with common Top-Level Domains (TLDs).yyyy-mm-dddd/mm/yyyymm/dd/yyyy978346800 becomes Mon 1 January 2001 11:00:00 UTC",
- run: DateTime.run_from_unix_timestamp,
- input_type: "number",
- output_type: "string",
- args: [
- {
- name: "Units",
- type: "option",
- value: DateTime.UNITS
- }
- ]
- },
- "To UNIX Timestamp": {
- description: "Parses a datetime string and returns the corresponding UNIX timestamp.Mon 1 January 2001 11:00:00 UTC becomes 978346800",
- run: DateTime.run_to_unix_timestamp,
- input_type: "string",
- output_type: "number",
- args: [
- {
- name: "Units",
- type: "option",
- value: DateTime.UNITS
- }
- ]
- },
- "Translate DateTime Format": {
- description: "Parses a datetime string in one format and re-writes it in another.a-z becomes abcdefghijklmnopqrstuvwxyz.",
- run: SeqUtils.run_expand_alph_range,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Delimiter",
- type: "binary_string",
- value: ""
- }
- ]
- },
- "Diff": {
- description: "Compares two inputs (separated by the specified delimiter) and highlights the differences between them.",
- run: StrUtils.run_diff,
- input_type: "string",
- output_type: "html",
- args: [
- {
- name: "Sample delimiter",
- type: "binary_string",
- value: StrUtils.DIFF_SAMPLE_DELIMITER
- },
- {
- name: "Diff by",
- type: "option",
- value: StrUtils.DIFF_BY
- },
- {
- name: "Show added",
- type: "boolean",
- value: true
- },
- {
- name: "Show removed",
- type: "boolean",
- value: true
- },
- {
- name: "Ignore whitespace (relevant for word and line)",
- type: "boolean",
- value: false
- }
- ]
- },
- "Parse UNIX file permissions": {
- description: "Given a UNIX/Linux file permission string in octal or textual format, this operation explains which permissions are granted to which user groups.755) or textual (e.g. drwxr-xr-x) format.",
- run: OS.run_parse_unix_perms,
- input_type: "string",
- output_type: "string",
- args: []
- },
- "Swap endianness": {
- description: "Switches the data from big-endian to little-endian or vice-versa. Data can be read in as hexadecimal or raw bytes. It will be returned in the same format as it is entered.",
- run: Endian.run_swap_endianness,
- highlight: true,
- highlight_reverse: true,
- input_type: "string",
- output_type: "string",
- args: [
- {
- name: "Data format",
- type: "option",
- value: Endian.DATA_FORMAT
- },
- {
- name: "Word length (bytes)",
- type: "number",
- value: Endian.WORD_LENGTH
- },
- {
- name: "Pad incomplete words",
- type: "boolean",
- value: Endian.PAD_INCOMPLETE_WORDS
- }
- ]
- },
- "Syntax highlighter": {
- description: "Adds syntax highlighting to a range of source code languages. Note that this will not indent the code. Use one of the 'Beautify' operations for that.",
- run: Code.run_syntax_highlight,
- highlight: true,
- highlight_reverse: true,
- input_type: "string",
- output_type: "html",
- args: [
- {
- name: "Language/File extension",
- type: "option",
- value: Code.LANGUAGES
- },
- {
- name: "Display line numbers",
- type: "boolean",
- value: Code.LINE_NUMS
- }
- ]
- },
- "Parse escaped string": {
- description: "Replaces escaped characters with the bytes they represent.Hello\\nWorld becomes Hello
World",
- run: StrUtils.run_parse_escaped_string,
- input_type: "string",
- output_type: "string",
- args: []
- },
- "TCP/IP Checksum": {
- description: "Calculates the checksum for a TCP (Transport Control Protocol) or IP (Internet Protocol) header from an input of raw bytes.",
- run: Checksum.run_tcp_ip,
- input_type: "byte_array",
- output_type: "string",
- args: []
- },
- "Parse colour code": {
- description: "Converts a colour code in a standard format to other standard formats and displays the colour itself.#d9edf7rgba(217,237,247,1)hsla(200,65%,91%,1)cmyk(0.12, 0.04, 0.00, 0.03)window.crypto if available and falling back to Math.random if not.",
- run: UUID.run_generate_v4,
- input_type: "string",
- output_type: "string",
- args: []
- }
-};
\ No newline at end of file
+const OperationConfig = {
+ Fork: {
+ description: "Split the input data up based on the specified delimiter and run all subsequent operations on each branch separately.aGVsbG8= becomes hello',
+ run: Base64.run_from,
+ highlight: Base64.highlight_from,
+ highlight_reverse: Base64.highlight_to,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Alphabet',
+ type: 'editable_option',
+ value: Base64.ALPHABET_OPTIONS,
+ },
+ {
+ name: 'Remove non‑alphabet chars',
+ type: 'boolean',
+ value: Base64.REMOVE_NON_ALPH_CHARS,
+ },
+ ],
+ },
+ 'To Base64': {
+ description: 'Base64 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers.hello becomes aGVsbG8=',
+ run: Base64.run_to,
+ highlight: Base64.highlight_to,
+ highlight_reverse: Base64.highlight_from,
+ input_type: 'byte_array',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Alphabet',
+ type: 'editable_option',
+ value: Base64.ALPHABET_OPTIONS,
+ },
+ ],
+ },
+ 'From Base32': {
+ description: 'Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.',
+ run: Base64.run_from_32,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Alphabet',
+ type: 'binary_string',
+ value: Base64.BASE32_ALPHABET,
+ },
+ {
+ name: 'Remove non‑alphabet chars',
+ type: 'boolean',
+ value: Base64.REMOVE_NON_ALPH_CHARS,
+ },
+ ],
+ },
+ 'To Base32': {
+ description: 'Base32 is a notation for encoding arbitrary byte data using a restricted set of symbols that can be conveniently used by humans and processed by computers. It uses a smaller set of characters than Base64, usually the uppercase alphabet and the numbers 2 to 7.',
+ run: Base64.run_to_32,
+ input_type: 'byte_array',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Alphabet',
+ type: 'binary_string',
+ value: Base64.BASE32_ALPHABET,
+ },
+ ],
+ },
+ 'Show Base64 offsets': {
+ description: "When a string is within a block of data and the whole block is Base64'd, the string itself could be represented in Base64 in three distinct ways depending on its offset within the block.fe023da5fe023da5',
+ run: BitwiseOp.run_and,
+ highlight: true,
+ highlight_reverse: true,
+ input_type: 'byte_array',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Key',
+ type: 'toggle_string',
+ value: '',
+ toggle_values: BitwiseOp.KEY_FORMAT,
+ },
+ ],
+ },
+ OR: {
+ description: 'OR the input with the given key.fe023da5',
+ run: BitwiseOp.run_or,
+ highlight: true,
+ highlight_reverse: true,
+ input_type: 'byte_array',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Key',
+ type: 'toggle_string',
+ value: '',
+ toggle_values: BitwiseOp.KEY_FORMAT,
+ },
+ ],
+ },
+ ADD: {
+ description: 'ADD the input with the given key (e.g. fe023da5), MOD 255',
+ run: BitwiseOp.run_add,
+ highlight: true,
+ highlight_reverse: true,
+ input_type: 'byte_array',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Key',
+ type: 'toggle_string',
+ value: '',
+ toggle_values: BitwiseOp.KEY_FORMAT,
+ },
+ ],
+ },
+ SUB: {
+ description: 'SUB the input with the given key (e.g. fe023da5), MOD 255',
+ run: BitwiseOp.run_sub,
+ highlight: true,
+ highlight_reverse: true,
+ input_type: 'byte_array',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Key',
+ type: 'toggle_string',
+ value: '',
+ toggle_values: BitwiseOp.KEY_FORMAT,
+ },
+ ],
+ },
+ 'From Hex': {
+ description: 'Converts a hexadecimal byte string back into a its raw value.ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a becomes the UTF-8 encoded string Γειά σου',
+ run: ByteRepr.run_from_hex,
+ highlight: ByteRepr.highlight_from,
+ highlight_reverse: ByteRepr.highlight_to,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'option',
+ value: ByteRepr.HEX_DELIM_OPTIONS,
+ },
+ ],
+ },
+ 'To Hex': {
+ description: 'Converts the input string to hexadecimal bytes separated by the specified delimiter.Γειά σου becomes ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a',
+ run: ByteRepr.run_to_hex,
+ highlight: ByteRepr.highlight_to,
+ highlight_reverse: ByteRepr.highlight_from,
+ input_type: 'byte_array',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'option',
+ value: ByteRepr.HEX_DELIM_OPTIONS,
+ },
+ ],
+ },
+ 'From Charcode': {
+ description: 'Converts unicode character codes back into text.0393 03b5 03b9 03ac 20 03c3 03bf 03c5 becomes Γειά σου',
+ run: ByteRepr.run_from_charcode,
+ highlight: ByteRepr.highlight_from,
+ highlight_reverse: ByteRepr.highlight_to,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'option',
+ value: ByteRepr.DELIM_OPTIONS,
+ },
+ {
+ name: 'Base',
+ type: 'number',
+ value: ByteRepr.CHARCODE_BASE,
+ },
+ ],
+ },
+ 'To Charcode': {
+ description: 'Converts text to its unicode character code equivalent.Γειά σου becomes 0393 03b5 03b9 03ac 20 03c3 03bf 03c5',
+ run: ByteRepr.run_to_charcode,
+ highlight: ByteRepr.highlight_to,
+ highlight_reverse: ByteRepr.highlight_from,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'option',
+ value: ByteRepr.DELIM_OPTIONS,
+ },
+ {
+ name: 'Base',
+ type: 'number',
+ value: ByteRepr.CHARCODE_BASE,
+ },
+ ],
+ },
+ 'From Binary': {
+ description: 'Converts a binary string back into its raw form.01001000 01101001 becomes Hi',
+ run: ByteRepr.run_from_binary,
+ highlight: ByteRepr.highlight_from_binary,
+ highlight_reverse: ByteRepr.highlight_to_binary,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'option',
+ value: ByteRepr.BIN_DELIM_OPTIONS,
+ },
+ ],
+ },
+ 'To Binary': {
+ description: 'Displays the input data as a binary string.Hi becomes 01001000 01101001',
+ run: ByteRepr.run_to_binary,
+ highlight: ByteRepr.highlight_to_binary,
+ highlight_reverse: ByteRepr.highlight_from_binary,
+ input_type: 'byte_array',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'option',
+ value: ByteRepr.BIN_DELIM_OPTIONS,
+ },
+ ],
+ },
+ 'From Decimal': {
+ description: 'Converts the data from an ordinal integer array back into its raw form.72 101 108 108 111 becomes Hello',
+ run: ByteRepr.run_from_decimal,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'option',
+ value: ByteRepr.DELIM_OPTIONS,
+ },
+ ],
+ },
+ 'To Decimal': {
+ description: 'Converts the input data to an ordinal integer array.Hello becomes 72 101 108 108 111',
+ run: ByteRepr.run_to_decimal,
+ input_type: 'byte_array',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'option',
+ value: ByteRepr.DELIM_OPTIONS,
+ },
+ ],
+ },
+ 'From Hexdump': {
+ description: 'Attempts to convert a hexdump back into raw data. This operation supports many different hexdump variations, but probably not all. Make sure you verify that the data it gives you is correct before continuing analysis.',
+ run: Hexdump.run_from,
+ highlight: Hexdump.highlight_from,
+ highlight_reverse: Hexdump.highlight_to,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [],
+ },
+ 'To Hexdump': {
+ description: 'Creates a hexdump of the input data, displaying both the hexademinal values of each byte and an ASCII representation alongside.',
+ run: Hexdump.run_to,
+ highlight: Hexdump.highlight_to,
+ highlight_reverse: Hexdump.highlight_from,
+ input_type: 'byte_array',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Width',
+ type: 'number',
+ value: Hexdump.WIDTH,
+ },
+ {
+ name: 'Upper case hex',
+ type: 'boolean',
+ value: Hexdump.UPPER_CASE,
+ },
+ {
+ name: 'Include final length',
+ type: 'boolean',
+ value: Hexdump.INCLUDE_FINAL_LENGTH,
+ },
+ ],
+ },
+ 'From Base': {
+ description: 'Converts a number to decimal from a given numerical base.',
+ run: Base.run_from,
+ input_type: 'string',
+ output_type: 'number',
+ args: [
+ {
+ name: 'Radix',
+ type: 'number',
+ value: Base.DEFAULT_RADIX,
+ },
+ ],
+ },
+ 'To Base': {
+ description: 'Converts a decimal number to a given numerical base.',
+ run: Base.run_to,
+ input_type: 'number',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Radix',
+ type: 'number',
+ value: Base.DEFAULT_RADIX,
+ },
+ ],
+ },
+ 'From HTML Entity': {
+ description: 'Converts HTML entities back to characters& becomes &', // tags required to stop the browser just printing &
+ run: HTML.run_from_entity,
+ input_type: 'string',
+ output_type: 'string',
+ args: [],
+ },
+ 'To HTML Entity': {
+ description: 'Converts characters to HTML entities& becomes &', // tags required to stop the browser just printing &
+ run: HTML.run_to_entity,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Convert all characters',
+ type: 'boolean',
+ value: HTML.CONVERT_ALL,
+ },
+ {
+ name: 'Convert to',
+ type: 'option',
+ value: HTML.CONVERT_OPTIONS,
+ },
+ ],
+ },
+ 'Strip HTML tags': {
+ description: 'Removes all HTML tags from the input.',
+ run: HTML.run_strip_tags,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Remove indentation',
+ type: 'boolean',
+ value: HTML.REMOVE_INDENTATION,
+ },
+ {
+ name: 'Remove excess line breaks',
+ type: 'boolean',
+ value: HTML.REMOVE_LINE_BREAKS,
+ },
+ ],
+ },
+ 'URL Decode': {
+ description: 'Converts URI/URL percent-encoded characters back to their raw values.%3d becomes =',
+ run: URL_.run_from,
+ input_type: 'string',
+ output_type: 'string',
+ args: [],
+ },
+ 'URL Encode': {
+ description: 'Encodes problematic characters into percent-encoding, a format supported by URIs/URLs.= becomes %3d',
+ run: URL_.run_to,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Encode all special chars',
+ type: 'boolean',
+ value: URL_.ENCODE_ALL,
+ },
+ ],
+ },
+ 'Parse URI': {
+ description: 'Pretty prints complicated Uniform Resource Identifier (URI) strings for ease of reading. Particularly useful for Uniform Resource Locators (URLs) with a lot of arguments.',
+ run: URL_.run_parse,
+ input_type: 'string',
+ output_type: 'string',
+ args: [],
+ },
+ 'Unescape Unicode Characters': {
+ description: 'Converts unicode-escaped character notation back into raw characters.\\u%uU+\\u03c3\\u03bf\\u03c5 becomes σου',
+ run: Unicode.run_unescape,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Prefix',
+ type: 'option',
+ value: Unicode.PREFIXES,
+ },
+ ],
+ },
+ 'From Quoted Printable': {
+ description: 'Converts QP-encoded text back to standard text.',
+ run: QuotedPrintable.run_from,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [],
+ },
+ 'To Quoted Printable': {
+ description: "Quoted-Printable, or QP encoding, is an encoding using printable ASCII characters (alphanumeric and the equals sign '=') to transmit 8-bit data over a 7-bit data path or, generally, over a medium which is not 8-bit clean. It is defined as a MIME content transfer encoding for use in e-mail.mnchen-3ya decodes to münchen',
+ run: Punycode.run_to_unicode,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Internationalised domain name',
+ type: 'boolean',
+ value: Punycode.IDN,
+ },
+ ],
+ },
+ 'To Punycode': {
+ description: 'Punycode is a way to represent Unicode with the limited character subset of ASCII supported by the Domain Name System.münchen encodes to mnchen-3ya',
+ run: Punycode.run_to_ascii,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Internationalised domain name',
+ type: 'boolean',
+ value: Punycode.IDN,
+ },
+ ],
+ },
+ 'From Hex Content': {
+ description: 'Translates hexadecimal bytes in text back to raw bytes.foo|3d|bar becomes foo=bar.',
+ run: ByteRepr.run_from_hex_content,
+ input_type: 'string',
+ output_type: 'byte_array',
+ args: [],
+ },
+ 'To Hex Content': {
+ description: 'Converts special characters in a string to hexadecimal.foo=bar becomes foo|3d|bar.',
+ run: ByteRepr.run_to_hex_content,
+ input_type: 'byte_array',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Convert',
+ type: 'option',
+ value: ByteRepr.HEX_CONTENT_CONVERT_WHICH,
+ },
+ {
+ name: 'Print spaces between bytes',
+ type: 'boolean',
+ value: ByteRepr.HEX_CONTENT_SPACES_BETWEEN_BYTES,
+ },
+ ],
+ },
+ 'Change IP format': {
+ description: 'Convert an IP address from one format to another, e.g. 172.20.23.54 to ac141736',
+ run: IP.run_change_ip_format,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Input format',
+ type: 'option',
+ value: IP.IP_FORMAT_LIST,
+ },
+ {
+ name: 'Output format',
+ type: 'option',
+ value: IP.IP_FORMAT_LIST,
+ },
+ ],
+ },
+ 'Parse IP range': {
+ description: 'Given a CIDR range (e.g. 10.0.0.0/24) or a hyphenated range (e.g. 10.0.0.0 - 10.0.1.0), this operation provides network information and enumerates all IP addresses in the range.0x00) from the input.',
+ run: Tidy.run_remove_nulls,
+ input_type: 'byte_array',
+ output_type: 'byte_array',
+ args: [],
+ },
+ 'Drop bytes': {
+ description: 'Cuts the specified number of bytes out of the data.',
+ run: Tidy.run_drop_bytes,
+ input_type: 'byte_array',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Start',
+ type: 'number',
+ value: Tidy.DROP_START,
+ },
+ {
+ name: 'Length',
+ type: 'number',
+ value: Tidy.DROP_LENGTH,
+ },
+ {
+ name: 'Apply to each line',
+ type: 'boolean',
+ value: Tidy.APPLY_TO_EACH_LINE,
+ },
+ ],
+ },
+ 'Take bytes': {
+ description: 'Takes a slice of the specified number of bytes from the data.',
+ run: Tidy.run_take_bytes,
+ input_type: 'byte_array',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'Start',
+ type: 'number',
+ value: Tidy.TAKE_START,
+ },
+ {
+ name: 'Length',
+ type: 'number',
+ value: Tidy.TAKE_LENGTH,
+ },
+ {
+ name: 'Apply to each line',
+ type: 'boolean',
+ value: Tidy.APPLY_TO_EACH_LINE,
+ },
+ ],
+ },
+ 'Pad lines': {
+ description: 'Add the specified number of the specified character to the beginning or end of each line',
+ run: Tidy.run_pad,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Position',
+ type: 'option',
+ value: Tidy.PAD_POSITION,
+ },
+ {
+ name: 'Length',
+ type: 'number',
+ value: Tidy.PAD_LENGTH,
+ },
+ {
+ name: 'Character',
+ type: 'binary_short_string',
+ value: Tidy.PAD_CHAR,
+ },
+ ],
+ },
+ Reverse: {
+ description: 'Reverses the input string.',
+ run: SeqUtils.run_reverse,
+ input_type: 'byte_array',
+ output_type: 'byte_array',
+ args: [
+ {
+ name: 'By',
+ type: 'option',
+ value: SeqUtils.REVERSE_BY,
+ },
+ ],
+ },
+ Sort: {
+ description: 'Alphabetically sorts strings separated by the specified delimiter.710.65.0.456, this will match 10.65.0.45 so always check the original input!',
+ run: Extract.run_ip,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'IPv4',
+ type: 'boolean',
+ value: Extract.INCLUDE_IPV4,
+ },
+ {
+ name: 'IPv6',
+ type: 'boolean',
+ value: Extract.INCLUDE_IPV6,
+ },
+ {
+ name: 'Remove local IPv4 addresses',
+ type: 'boolean',
+ value: Extract.REMOVE_LOCAL,
+ },
+ {
+ name: 'Display total',
+ type: 'boolean',
+ value: Extract.DISPLAY_TOTAL,
+ },
+ ],
+ },
+ 'Extract email addresses': {
+ description: 'Extracts all email addresses from the input.',
+ run: Extract.run_email,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Display total',
+ type: 'boolean',
+ value: Extract.DISPLAY_TOTAL,
+ },
+ ],
+ },
+ 'Extract MAC addresses': {
+ description: 'Extracts all Media Access Control (MAC) addresses from the input.',
+ run: Extract.run_mac,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Display total',
+ type: 'boolean',
+ value: Extract.DISPLAY_TOTAL,
+ },
+ ],
+ },
+ 'Extract URLs': {
+ description: 'Extracts Uniform Resource Locators (URLs) from the input. The protocol (http, ftp etc.) is required otherwise there will be far too many false positives.',
+ run: Extract.run_urls,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Display total',
+ type: 'boolean',
+ value: Extract.DISPLAY_TOTAL,
+ },
+ ],
+ },
+ 'Extract domains': {
+ description: 'Extracts domain names with common Top-Level Domains (TLDs).yyyy-mm-dddd/mm/yyyymm/dd/yyyy978346800 becomes Mon 1 January 2001 11:00:00 UTC',
+ run: DateTime.run_from_unix_timestamp,
+ input_type: 'number',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Units',
+ type: 'option',
+ value: DateTime.UNITS,
+ },
+ ],
+ },
+ 'To UNIX Timestamp': {
+ description: 'Parses a datetime string and returns the corresponding UNIX timestamp.Mon 1 January 2001 11:00:00 UTC becomes 978346800',
+ run: DateTime.run_to_unix_timestamp,
+ input_type: 'string',
+ output_type: 'number',
+ args: [
+ {
+ name: 'Units',
+ type: 'option',
+ value: DateTime.UNITS,
+ },
+ ],
+ },
+ 'Translate DateTime Format': {
+ description: 'Parses a datetime string in one format and re-writes it in another.a-z becomes abcdefghijklmnopqrstuvwxyz.',
+ run: SeqUtils.run_expand_alph_range,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Delimiter',
+ type: 'binary_string',
+ value: '',
+ },
+ ],
+ },
+ Diff: {
+ description: 'Compares two inputs (separated by the specified delimiter) and highlights the differences between them.',
+ run: StrUtils.run_diff,
+ input_type: 'string',
+ output_type: 'html',
+ args: [
+ {
+ name: 'Sample delimiter',
+ type: 'binary_string',
+ value: StrUtils.DIFF_SAMPLE_DELIMITER,
+ },
+ {
+ name: 'Diff by',
+ type: 'option',
+ value: StrUtils.DIFF_BY,
+ },
+ {
+ name: 'Show added',
+ type: 'boolean',
+ value: true,
+ },
+ {
+ name: 'Show removed',
+ type: 'boolean',
+ value: true,
+ },
+ {
+ name: 'Ignore whitespace (relevant for word and line)',
+ type: 'boolean',
+ value: false,
+ },
+ ],
+ },
+ 'Parse UNIX file permissions': {
+ description: 'Given a UNIX/Linux file permission string in octal or textual format, this operation explains which permissions are granted to which user groups.755) or textual (e.g. drwxr-xr-x) format.',
+ run: OS.run_parse_unix_perms,
+ input_type: 'string',
+ output_type: 'string',
+ args: [],
+ },
+ 'Swap endianness': {
+ description: 'Switches the data from big-endian to little-endian or vice-versa. Data can be read in as hexadecimal or raw bytes. It will be returned in the same format as it is entered.',
+ run: Endian.run_swap_endianness,
+ highlight: true,
+ highlight_reverse: true,
+ input_type: 'string',
+ output_type: 'string',
+ args: [
+ {
+ name: 'Data format',
+ type: 'option',
+ value: Endian.DATA_FORMAT,
+ },
+ {
+ name: 'Word length (bytes)',
+ type: 'number',
+ value: Endian.WORD_LENGTH,
+ },
+ {
+ name: 'Pad incomplete words',
+ type: 'boolean',
+ value: Endian.PAD_INCOMPLETE_WORDS,
+ },
+ ],
+ },
+ 'Syntax highlighter': {
+ description: "Adds syntax highlighting to a range of source code languages. Note that this will not indent the code. Use one of the 'Beautify' operations for that.",
+ run: Code.run_syntax_highlight,
+ highlight: true,
+ highlight_reverse: true,
+ input_type: 'string',
+ output_type: 'html',
+ args: [
+ {
+ name: 'Language/File extension',
+ type: 'option',
+ value: Code.LANGUAGES,
+ },
+ {
+ name: 'Display line numbers',
+ type: 'boolean',
+ value: Code.LINE_NUMS,
+ },
+ ],
+ },
+ 'Parse escaped string': {
+ description: 'Replaces escaped characters with the bytes they represent.Hello\\nWorld becomes Hello
World',
+ run: StrUtils.run_parse_escaped_string,
+ input_type: 'string',
+ output_type: 'string',
+ args: [],
+ },
+ 'TCP/IP Checksum': {
+ description: 'Calculates the checksum for a TCP (Transport Control Protocol) or IP (Internet Protocol) header from an input of raw bytes.',
+ run: Checksum.run_tcp_ip,
+ input_type: 'byte_array',
+ output_type: 'string',
+ args: [],
+ },
+ 'Parse colour code': {
+ description: 'Converts a colour code in a standard format to other standard formats and displays the colour itself.#d9edf7rgba(217,237,247,1)hsla(200,65%,91%,1)cmyk(0.12, 0.04, 0.00, 0.03)window.crypto if available and falling back to Math.random if not.',
+ run: UUID.run_generate_v4,
+ input_type: 'string',
+ output_type: 'string',
+ args: [],
+ },
+};
diff --git a/src/js/core/Chef.js b/src/js/core/Chef.js
index 459cdcf9..5edf2f7e 100755
--- a/src/js/core/Chef.js
+++ b/src/js/core/Chef.js
@@ -7,8 +7,8 @@
*
* @class
*/
-var Chef = function() {
- this.dish = new Dish();
+const Chef = function () {
+ this.dish = new Dish();
};
@@ -30,62 +30,62 @@ var Chef = function() {
* @returns {number} response.duration - The number of ms it took to execute the recipe
* @returns {number} response.error - The error object thrown by a failed operation (false if no error)
*/
-Chef.prototype.bake = function(input_text, recipe_config, options, progress, step) {
- var start_time = new Date().getTime(),
- recipe = new Recipe(recipe_config),
- contains_fc = recipe.contains_flow_control(),
- error = false;
-
+Chef.prototype.bake = function (input_text, recipe_config, options, progress, step) {
+ let start_time = new Date().getTime(),
+ recipe = new Recipe(recipe_config),
+ contains_fc = recipe.contains_flow_control(),
+ error = false;
+
// Reset attempt_highlight flag
- if (options.hasOwnProperty("attempt_highlight")) {
- options.attempt_highlight = true;
- }
-
- if (contains_fc) options.attempt_highlight = false;
-
+ if (options.hasOwnProperty('attempt_highlight')) {
+ options.attempt_highlight = true;
+ }
+
+ if (contains_fc) options.attempt_highlight = false;
+
// Clean up progress
- if (progress >= recipe_config.length) {
- progress = 0;
- }
-
- if (step) {
+ if (progress >= recipe_config.length) {
+ progress = 0;
+ }
+
+ if (step) {
// Unset breakpoint on this step
- recipe.set_breakpoint(progress, false);
+ recipe.set_breakpoint(progress, false);
// Set breakpoint on next step
- recipe.set_breakpoint(progress + 1, true);
- }
-
+ recipe.set_breakpoint(progress + 1, true);
+ }
+
// If stepping with flow control, we have to start from the beginning
// but still want to skip all previous breakpoints
- if (progress > 0 && contains_fc) {
- recipe.remove_breaks_up_to(progress);
- progress = 0;
- }
-
- // If starting from scratch, load data
- if (progress === 0) {
- this.dish.set(input_text, Dish.STRING);
- }
+ if (progress > 0 && contains_fc) {
+ recipe.remove_breaks_up_to(progress);
+ progress = 0;
+ }
- try {
- progress = recipe.execute(this.dish, progress);
- } catch (err) {
+ // If starting from scratch, load data
+ if (progress === 0) {
+ this.dish.set(input_text, Dish.STRING);
+ }
+
+ try {
+ progress = recipe.execute(this.dish, progress);
+ } catch (err) {
// We can't throw the error from here as we will return in the finally block and ignore it
// so we return the error in the result instead.
- error = err;
- progress = err.progress;
- } finally {
- return {
- result: this.dish.type == Dish.HTML ?
+ error = err;
+ progress = err.progress;
+ } finally {
+ return {
+ result: this.dish.type == Dish.HTML ?
this.dish.get(Dish.HTML) :
this.dish.get(Dish.STRING),
- type: Dish.enum_lookup(this.dish.type),
- progress: progress,
- options: options,
- duration: new Date().getTime() - start_time,
- error: error
- };
- }
+ type: Dish.enum_lookup(this.dish.type),
+ progress,
+ options,
+ duration: new Date().getTime() - start_time,
+ error,
+ };
+ }
};
@@ -94,27 +94,27 @@ Chef.prototype.bake = function(input_text, recipe_config, options, progress, ste
* it swaps out the memory for that tab. If the CyberChef tab has been unfocused for more than a
* minute, we run a silent bake which will force the browser to load and cache all the relevant
* JavaScript code needed to do a real bake.
- *
+ *
* This will stop baking taking a long time when the CyberChef browser tab has been unfocused for a
* long time and the browser has swapped out all its memory.
- *
+ *
* The output will not be modified (hence "silent" bake).
- *
+ *
* This will only actually execute the recipe if auto-bake is enabled, otherwise it will just load
* the recipe, ingredients and dish.
*
* @param {Object[]} recipe_config - The recipe configuration object
* @returns {number} The time it took to run the silent bake in milliseconds.
*/
-Chef.prototype.silent_bake = function(recipe_config) {
- var start_time = new Date().getTime(),
- recipe = new Recipe(recipe_config),
- dish = new Dish("", Dish.STRING);
-
- try {
- recipe.execute(dish);
- } catch(err) {
+Chef.prototype.silent_bake = function (recipe_config) {
+ let start_time = new Date().getTime(),
+ recipe = new Recipe(recipe_config),
+ dish = new Dish('', Dish.STRING);
+
+ try {
+ recipe.execute(dish);
+ } catch (err) {
// Suppress all errors
- }
- return new Date().getTime() - start_time;
+ }
+ return new Date().getTime() - start_time;
};
diff --git a/src/js/core/Dish.js b/src/js/core/Dish.js
index c69ebef3..37e531cb 100755
--- a/src/js/core/Dish.js
+++ b/src/js/core/Dish.js
@@ -9,9 +9,9 @@
* @param {byte_array|string|number} value - The value of the input data.
* @param {number} type - The data type of value, see Dish enums.
*/
-var Dish = function(value, type) {
- this.value = value || typeof value == "string" ? value : null;
- this.type = type || Dish.BYTE_ARRAY;
+const Dish = function (value, type) {
+ this.value = value || typeof value === 'string' ? value : null;
+ this.type = type || Dish.BYTE_ARRAY;
};
@@ -48,23 +48,23 @@ Dish.HTML = 3;
* @param {string} type_str - The name of the data type.
* @returns {number} The data type enum value.
*/
-Dish.type_enum = function(type_str) {
- switch (type_str) {
- case "byte_array":
- case "Byte array":
- return Dish.BYTE_ARRAY;
- case "string":
- case "String":
- return Dish.STRING;
- case "number":
- case "Number":
- return Dish.NUMBER;
- case "html":
- case "HTML":
- return Dish.HTML;
- default:
- throw "Invalid data type string. No matching enum.";
- }
+Dish.type_enum = function (type_str) {
+ switch (type_str) {
+ case 'byte_array':
+ case 'Byte array':
+ return Dish.BYTE_ARRAY;
+ case 'string':
+ case 'String':
+ return Dish.STRING;
+ case 'number':
+ case 'Number':
+ return Dish.NUMBER;
+ case 'html':
+ case 'HTML':
+ return Dish.HTML;
+ default:
+ throw 'Invalid data type string. No matching enum.';
+ }
};
@@ -75,19 +75,19 @@ Dish.type_enum = function(type_str) {
* @param {string} type_enum - The enum value of the data type.
* @returns {number} The data type as a string.
*/
-Dish.enum_lookup = function(type_enum) {
- switch (type_enum) {
- case Dish.BYTE_ARRAY:
- return "byte_array";
- case Dish.STRING:
- return "string";
- case Dish.NUMBER:
- return "number";
- case Dish.HTML:
- return "html";
- default:
- throw "Invalid data type enum. No matching type.";
- }
+Dish.enum_lookup = function (type_enum) {
+ switch (type_enum) {
+ case Dish.BYTE_ARRAY:
+ return 'byte_array';
+ case Dish.STRING:
+ return 'string';
+ case Dish.NUMBER:
+ return 'number';
+ case Dish.HTML:
+ return 'html';
+ default:
+ throw 'Invalid data type enum. No matching type.';
+ }
};
@@ -97,14 +97,14 @@ Dish.enum_lookup = function(type_enum) {
* @param {byte_array|string|number} value - The value of the input data.
* @param {number} type - The data type of value, see Dish enums.
*/
-Dish.prototype.set = function(value, type) {
- this.value = value;
- this.type = type;
-
- if (!this.valid()) {
- var sample = Utils.truncate(JSON.stringify(this.value), 13);
- throw "Data is not a valid " + Dish.enum_lookup(type) + ": " + sample;
- }
+Dish.prototype.set = function (value, type) {
+ this.value = value;
+ this.type = type;
+
+ if (!this.valid()) {
+ const sample = Utils.truncate(JSON.stringify(this.value), 13);
+ throw `Data is not a valid ${Dish.enum_lookup(type)}: ${sample}`;
+ }
};
@@ -114,11 +114,11 @@ Dish.prototype.set = function(value, type) {
* @param {number} type - The data type of value, see Dish enums.
* @returns {byte_array|string|number} The value of the output data.
*/
-Dish.prototype.get = function(type) {
- if (this.type != type) {
- this.translate(type);
- }
- return this.value;
+Dish.prototype.get = function (type) {
+ if (this.type != type) {
+ this.translate(type);
+ }
+ return this.value;
};
@@ -127,39 +127,39 @@ Dish.prototype.get = function(type) {
*
* @param {number} to_type - The data type of value, see Dish enums.
*/
-Dish.prototype.translate = function(to_type) {
+Dish.prototype.translate = function (to_type) {
// Convert data to intermediate byte_array type
- switch (this.type) {
- case Dish.STRING:
- this.value = this.value ? Utils.str_to_byte_array(this.value) : [];
- this.type = Dish.BYTE_ARRAY;
- break;
- case Dish.NUMBER:
- this.value = typeof this.value == "number" ? Utils.str_to_byte_array(this.value.toString()) : [];
- this.type = Dish.BYTE_ARRAY;
- break;
- case Dish.HTML:
- this.value = this.value ? Utils.str_to_byte_array(Utils.strip_html_tags(this.value, true)) : [];
- this.type = Dish.BYTE_ARRAY;
- break;
- default:
- break;
- }
-
+ switch (this.type) {
+ case Dish.STRING:
+ this.value = this.value ? Utils.str_to_byte_array(this.value) : [];
+ this.type = Dish.BYTE_ARRAY;
+ break;
+ case Dish.NUMBER:
+ this.value = typeof this.value === 'number' ? Utils.str_to_byte_array(this.value.toString()) : [];
+ this.type = Dish.BYTE_ARRAY;
+ break;
+ case Dish.HTML:
+ this.value = this.value ? Utils.str_to_byte_array(Utils.strip_html_tags(this.value, true)) : [];
+ this.type = Dish.BYTE_ARRAY;
+ break;
+ default:
+ break;
+ }
+
// Convert from byte_array to to_type
- switch (to_type) {
- case Dish.STRING:
- case Dish.HTML:
- this.value = this.value ? Utils.byte_array_to_utf8(this.value) : "";
- this.type = Dish.STRING;
- break;
- case Dish.NUMBER:
- this.value = this.value ? parseFloat(Utils.byte_array_to_utf8(this.value)) : 0;
- this.type = Dish.NUMBER;
- break;
- default:
- break;
- }
+ switch (to_type) {
+ case Dish.STRING:
+ case Dish.HTML:
+ this.value = this.value ? Utils.byte_array_to_utf8(this.value) : '';
+ this.type = Dish.STRING;
+ break;
+ case Dish.NUMBER:
+ this.value = this.value ? parseFloat(Utils.byte_array_to_utf8(this.value)) : 0;
+ this.type = Dish.NUMBER;
+ break;
+ default:
+ break;
+ }
};
@@ -169,34 +169,34 @@ Dish.prototype.translate = function(to_type) {
*
* @returns {boolean} Whether the data is valid or not.
*/
-Dish.prototype.valid = function() {
- switch (this.type) {
- case Dish.BYTE_ARRAY:
- if (!(this.value instanceof Array)) {
- return false;
- }
-
+Dish.prototype.valid = function () {
+ switch (this.type) {
+ case Dish.BYTE_ARRAY:
+ if (!(this.value instanceof Array)) {
+ return false;
+ }
+
// Check that every value is a number between 0 - 255
- for (var i = 0; i < this.value.length; i++) {
- if (typeof this.value[i] != "number" ||
+ for (let i = 0; i < this.value.length; i++) {
+ if (typeof this.value[i] !== 'number' ||
this.value[i] < 0 ||
this.value[i] > 255) {
- return false;
- }
- }
- return true;
- case Dish.STRING:
- case Dish.HTML:
- if (typeof this.value == "string") {
- return true;
- }
- return false;
- case Dish.NUMBER:
- if (typeof this.value == "number") {
- return true;
- }
- return false;
- default:
- return false;
- }
+ return false;
+ }
+ }
+ return true;
+ case Dish.STRING:
+ case Dish.HTML:
+ if (typeof this.value === 'string') {
+ return true;
+ }
+ return false;
+ case Dish.NUMBER:
+ if (typeof this.value === 'number') {
+ return true;
+ }
+ return false;
+ default:
+ return false;
+ }
};
diff --git a/src/js/core/FlowControl.js b/src/js/core/FlowControl.js
index 51af24a0..1824c1f0 100755
--- a/src/js/core/FlowControl.js
+++ b/src/js/core/FlowControl.js
@@ -7,19 +7,19 @@
*
* @namespace
*/
-var FlowControl = {
+const FlowControl = {
/**
* @constant
* @default
*/
- FORK_DELIM: "\\n",
+ FORK_DELIM: '\\n',
/**
* @constant
* @default
*/
- MERGE_DELIM: "\\n",
-
+ MERGE_DELIM: '\\n',
+
/**
* Fork operation.
*
@@ -29,49 +29,50 @@ var FlowControl = {
* @param {Operation[]} state.op_list - The list of operations in the recipe.
* @returns {Object} The updated state of the recipe.
*/
- run_fork: function(state) {
- var op_list = state.op_list,
- input_type = op_list[state.progress].input_type,
- output_type = op_list[state.progress].output_type,
- input = state.dish.get(input_type),
- ings = op_list[state.progress].get_ing_values(),
- split_delim = ings[0],
- merge_delim = ings[1],
- sub_op_list = [],
- inputs = [];
-
- if (input)
- inputs = input.split(split_delim);
-
+ run_fork(state) {
+ let op_list = state.op_list,
+ input_type = op_list[state.progress].input_type,
+ output_type = op_list[state.progress].output_type,
+ input = state.dish.get(input_type),
+ ings = op_list[state.progress].get_ing_values(),
+ split_delim = ings[0],
+ merge_delim = ings[1],
+ sub_op_list = [],
+ inputs = [];
+
+ if (input) {
+ inputs = input.split(split_delim);
+ }
+
// Create sub_op_list for each tranche to operate on
// (all remaining operations unless we encounter a Merge)
- for (var i = state.progress + 1; i < op_list.length; i++) {
- if (op_list[i].name == "Merge" && !op_list[i].is_disabled()) {
- break;
- } else {
- sub_op_list.push(op_list[i]);
- }
- }
-
- var recipe = new Recipe(),
- output = "",
- progress;
-
- recipe.add_operations(sub_op_list);
-
+ for (var i = state.progress + 1; i < op_list.length; i++) {
+ if (op_list[i].name == 'Merge' && !op_list[i].is_disabled()) {
+ break;
+ } else {
+ sub_op_list.push(op_list[i]);
+ }
+ }
+
+ let recipe = new Recipe(),
+ output = '',
+ progress;
+
+ recipe.add_operations(sub_op_list);
+
// Run recipe over each tranche
- for (i = 0; i < inputs.length; i++) {
- var dish = new Dish(inputs[i], input_type);
- progress = recipe.execute(dish, 0);
- output += dish.get(output_type) + merge_delim;
- }
-
- state.dish.set(output, output_type);
- state.progress += progress;
- return state;
- },
-
-
+ for (i = 0; i < inputs.length; i++) {
+ const dish = new Dish(inputs[i], input_type);
+ progress = recipe.execute(dish, 0);
+ output += dish.get(output_type) + merge_delim;
+ }
+
+ state.dish.set(output, output_type);
+ state.progress += progress;
+ return state;
+ },
+
+
/**
* Merge operation.
*
@@ -81,24 +82,24 @@ var FlowControl = {
* @param {Operation[]} state.op_list - The list of operations in the recipe.
* @returns {Object} The updated state of the recipe.
*/
- run_merge: function(state) {
+ run_merge(state) {
// No need to actually do anything here. The fork operation will
// merge when it sees this operation.
- return state;
- },
-
-
+ return state;
+ },
+
+
/**
* @constant
* @default
*/
- JUMP_NUM: 0,
+ JUMP_NUM: 0,
/**
* @constant
* @default
*/
- MAX_JUMPS: 10,
-
+ MAX_JUMPS: 10,
+
/**
* Jump operation.
*
@@ -109,21 +110,21 @@ var FlowControl = {
* @param {number} state.num_jumps - The number of jumps taken so far.
* @returns {Object} The updated state of the recipe.
*/
- run_jump: function(state) {
- var ings = state.op_list[state.progress].get_ing_values(),
- jump_num = ings[0],
- max_jumps = ings[1];
-
- if (state.num_jumps >= max_jumps) {
- throw "Reached maximum jumps, sorry!";
- }
-
- state.progress += jump_num;
- state.num_jumps++;
- return state;
- },
-
-
+ run_jump(state) {
+ let ings = state.op_list[state.progress].get_ing_values(),
+ jump_num = ings[0],
+ max_jumps = ings[1];
+
+ if (state.num_jumps >= max_jumps) {
+ throw 'Reached maximum jumps, sorry!';
+ }
+
+ state.progress += jump_num;
+ state.num_jumps++;
+ return state;
+ },
+
+
/**
* Conditional Jump operation.
*
@@ -134,26 +135,26 @@ var FlowControl = {
* @param {number} state.num_jumps - The number of jumps taken so far.
* @returns {Object} The updated state of the recipe.
*/
- run_cond_jump: function(state) {
- var ings = state.op_list[state.progress].get_ing_values(),
- dish = state.dish,
- regex_str = ings[0],
- jump_num = ings[1],
- max_jumps = ings[2];
-
- if (state.num_jumps >= max_jumps) {
- throw "Reached maximum jumps, sorry!";
- }
-
- if (regex_str !== "" && dish.get(Dish.STRING).search(regex_str) > -1) {
- state.progress += jump_num;
- state.num_jumps++;
- }
-
- return state;
- },
-
-
+ run_cond_jump(state) {
+ let ings = state.op_list[state.progress].get_ing_values(),
+ dish = state.dish,
+ regex_str = ings[0],
+ jump_num = ings[1],
+ max_jumps = ings[2];
+
+ if (state.num_jumps >= max_jumps) {
+ throw 'Reached maximum jumps, sorry!';
+ }
+
+ if (regex_str !== '' && dish.get(Dish.STRING).search(regex_str) > -1) {
+ state.progress += jump_num;
+ state.num_jumps++;
+ }
+
+ return state;
+ },
+
+
/**
* Return operation.
*
@@ -163,9 +164,9 @@ var FlowControl = {
* @param {Operation[]} state.op_list - The list of operations in the recipe.
* @returns {Object} The updated state of the recipe.
*/
- run_return: function(state) {
- state.progress = state.op_list.length;
- return state;
- },
-
+ run_return(state) {
+ state.progress = state.op_list.length;
+ return state;
+ },
+
};
diff --git a/src/js/core/Ingredient.js b/src/js/core/Ingredient.js
index df551b6f..534d6ca9 100755
--- a/src/js/core/Ingredient.js
+++ b/src/js/core/Ingredient.js
@@ -8,14 +8,14 @@
* @class
* @param {Object} ingredient_config
*/
-var Ingredient = function(ingredient_config) {
- this.name = "";
- this.type = "";
- this.value = null;
-
- if (ingredient_config) {
- this._parse_config(ingredient_config);
- }
+const Ingredient = function (ingredient_config) {
+ this.name = '';
+ this.type = '';
+ this.value = null;
+
+ if (ingredient_config) {
+ this._parse_config(ingredient_config);
+ }
};
@@ -25,9 +25,9 @@ var Ingredient = function(ingredient_config) {
* @private
* @param {Object} ingredient_config
*/
-Ingredient.prototype._parse_config = function(ingredient_config) {
- this.name = ingredient_config.name;
- this.type = ingredient_config.type;
+Ingredient.prototype._parse_config = function (ingredient_config) {
+ this.name = ingredient_config.name;
+ this.type = ingredient_config.type;
};
@@ -36,8 +36,8 @@ Ingredient.prototype._parse_config = function(ingredient_config) {
*
* @returns {*}
*/
-Ingredient.prototype.get_config = function() {
- return this.value;
+Ingredient.prototype.get_config = function () {
+ return this.value;
};
@@ -46,8 +46,8 @@ Ingredient.prototype.get_config = function() {
*
* @param {*} value
*/
-Ingredient.prototype.set_value = function(value) {
- this.value = Ingredient.prepare(value, this.type);
+Ingredient.prototype.set_value = function (value) {
+ this.value = Ingredient.prepare(value, this.type);
};
@@ -59,28 +59,28 @@ Ingredient.prototype.set_value = function(value) {
* @param {*} data
* @param {string} type - The name of the data type.
*/
-Ingredient.prepare = function(data, type) {
- switch (type) {
- case "binary_string":
- case "binary_short_string":
- case "editable_option":
- return Utils.parse_escaped_chars(data);
- case "byte_array":
- if (typeof data == "string") {
- data = data.replace(/\s+/g, '');
- return Utils.hex_to_byte_array(data);
- } else {
- return data;
- }
- break;
- case "number":
- var number = parseFloat(data);
- if (isNaN(number)) {
- var sample = Utils.truncate(data.toString(), 10);
- throw "Invalid ingredient value. Not a number: " + sample;
- }
- return number;
- default:
- return data;
- }
+Ingredient.prepare = function (data, type) {
+ switch (type) {
+ case 'binary_string':
+ case 'binary_short_string':
+ case 'editable_option':
+ return Utils.parse_escaped_chars(data);
+ case 'byte_array':
+ if (typeof data === 'string') {
+ data = data.replace(/\s+/g, '');
+ return Utils.hex_to_byte_array(data);
+ } else {
+ return data;
+ }
+ break;
+ case 'number':
+ var number = parseFloat(data);
+ if (isNaN(number)) {
+ const sample = Utils.truncate(data.toString(), 10);
+ throw `Invalid ingredient value. Not a number: ${sample}`;
+ }
+ return number;
+ default:
+ return data;
+ }
};
diff --git a/src/js/core/Operation.js b/src/js/core/Operation.js
index 26a1e279..9c6bd150 100755
--- a/src/js/core/Operation.js
+++ b/src/js/core/Operation.js
@@ -9,21 +9,21 @@
* @param {string} operation_name
* @param {Object} operation_config
*/
-var Operation = function(operation_name, operation_config) {
- this.name = operation_name;
- this.description = "";
- this.input_type = -1;
- this.output_type = -1;
- this.run = null;
- this.highlight = null;
- this.highlight_reverse = null;
- this.breakpoint = false;
- this.disabled = false;
- this.ing_list = [];
-
- if (operation_config) {
- this._parse_config(operation_config);
- }
+const Operation = function (operation_name, operation_config) {
+ this.name = operation_name;
+ this.description = '';
+ this.input_type = -1;
+ this.output_type = -1;
+ this.run = null;
+ this.highlight = null;
+ this.highlight_reverse = null;
+ this.breakpoint = false;
+ this.disabled = false;
+ this.ing_list = [];
+
+ if (operation_config) {
+ this._parse_config(operation_config);
+ }
};
@@ -33,20 +33,20 @@ var Operation = function(operation_name, operation_config) {
* @private
* @param {Object} operation_config
*/
-Operation.prototype._parse_config = function(operation_config) {
- this.description = operation_config.description;
- this.input_type = Dish.type_enum(operation_config.input_type);
- this.output_type = Dish.type_enum(operation_config.output_type);
- this.run = operation_config.run;
- this.highlight = operation_config.highlight;
- this.highlight_reverse = operation_config.highlight_reverse;
- this.flow_control = operation_config.flow_control;
+Operation.prototype._parse_config = function (operation_config) {
+ this.description = operation_config.description;
+ this.input_type = Dish.type_enum(operation_config.input_type);
+ this.output_type = Dish.type_enum(operation_config.output_type);
+ this.run = operation_config.run;
+ this.highlight = operation_config.highlight;
+ this.highlight_reverse = operation_config.highlight_reverse;
+ this.flow_control = operation_config.flow_control;
- for (var a = 0; a < operation_config.args.length; a++) {
- var ingredient_config = operation_config.args[a];
- var ingredient = new Ingredient(ingredient_config);
- this.add_ingredient(ingredient);
- }
+ for (let a = 0; a < operation_config.args.length; a++) {
+ const ingredient_config = operation_config.args[a];
+ const ingredient = new Ingredient(ingredient_config);
+ this.add_ingredient(ingredient);
+ }
};
@@ -55,19 +55,19 @@ Operation.prototype._parse_config = function(operation_config) {
*
* @returns {Object}
*/
-Operation.prototype.get_config = function() {
- var ingredient_config = [];
-
- for (var o = 0; o < this.ing_list.length; o++) {
- ingredient_config.push(this.ing_list[o].get_config());
- }
-
- var operation_config = {
- "op": this.name,
- "args": ingredient_config
- };
-
- return operation_config;
+Operation.prototype.get_config = function () {
+ const ingredient_config = [];
+
+ for (let o = 0; o < this.ing_list.length; o++) {
+ ingredient_config.push(this.ing_list[o].get_config());
+ }
+
+ const operation_config = {
+ op: this.name,
+ args: ingredient_config,
+ };
+
+ return operation_config;
};
@@ -76,8 +76,8 @@ Operation.prototype.get_config = function() {
*
* @param {Ingredient} ingredient
*/
-Operation.prototype.add_ingredient = function(ingredient) {
- this.ing_list.push(ingredient);
+Operation.prototype.add_ingredient = function (ingredient) {
+ this.ing_list.push(ingredient);
};
@@ -86,10 +86,10 @@ Operation.prototype.add_ingredient = function(ingredient) {
*
* @param {Object[]} ing_values
*/
-Operation.prototype.set_ing_values = function(ing_values) {
- for (var i = 0; i < ing_values.length; i++) {
- this.ing_list[i].set_value(ing_values[i]);
- }
+Operation.prototype.set_ing_values = function (ing_values) {
+ for (let i = 0; i < ing_values.length; i++) {
+ this.ing_list[i].set_value(ing_values[i]);
+ }
};
@@ -98,12 +98,12 @@ Operation.prototype.set_ing_values = function(ing_values) {
*
* @returns {Object[]}
*/
-Operation.prototype.get_ing_values = function() {
- var ing_values = [];
- for (var i = 0; i < this.ing_list.length; i++) {
- ing_values.push(this.ing_list[i].value);
- }
- return ing_values;
+Operation.prototype.get_ing_values = function () {
+ const ing_values = [];
+ for (let i = 0; i < this.ing_list.length; i++) {
+ ing_values.push(this.ing_list[i].value);
+ }
+ return ing_values;
};
@@ -112,8 +112,8 @@ Operation.prototype.get_ing_values = function() {
*
* @param {boolean} value
*/
-Operation.prototype.set_breakpoint = function(value) {
- this.breakpoint = !!value;
+Operation.prototype.set_breakpoint = function (value) {
+ this.breakpoint = !!value;
};
@@ -122,8 +122,8 @@ Operation.prototype.set_breakpoint = function(value) {
*
* @returns {boolean}
*/
-Operation.prototype.is_breakpoint = function() {
- return this.breakpoint;
+Operation.prototype.is_breakpoint = function () {
+ return this.breakpoint;
};
@@ -132,8 +132,8 @@ Operation.prototype.is_breakpoint = function() {
*
* @param {boolean} value
*/
-Operation.prototype.set_disabled = function(value) {
- this.disabled = !!value;
+Operation.prototype.set_disabled = function (value) {
+ this.disabled = !!value;
};
@@ -142,8 +142,8 @@ Operation.prototype.set_disabled = function(value) {
*
* @returns {boolean}
*/
-Operation.prototype.is_disabled = function() {
- return this.disabled;
+Operation.prototype.is_disabled = function () {
+ return this.disabled;
};
@@ -152,6 +152,6 @@ Operation.prototype.is_disabled = function() {
*
* @returns {boolean}
*/
-Operation.prototype.is_flow_control = function() {
- return this.flow_control;
+Operation.prototype.is_flow_control = function () {
+ return this.flow_control;
};
diff --git a/src/js/core/Recipe.js b/src/js/core/Recipe.js
index b93d7560..a4ba7542 100755
--- a/src/js/core/Recipe.js
+++ b/src/js/core/Recipe.js
@@ -8,12 +8,12 @@
* @class
* @param {Object} recipe_config
*/
-var Recipe = function(recipe_config) {
- this.op_list = [];
-
- if (recipe_config) {
- this._parse_config(recipe_config);
- }
+const Recipe = function (recipe_config) {
+ this.op_list = [];
+
+ if (recipe_config) {
+ this._parse_config(recipe_config);
+ }
};
@@ -23,16 +23,16 @@ var Recipe = function(recipe_config) {
* @private
* @param {Object} recipe_config
*/
-Recipe.prototype._parse_config = function(recipe_config) {
- for (var c = 0; c < recipe_config.length; c++) {
- var operation_name = recipe_config[c].op;
- var operation_config = OperationConfig[operation_name];
- var operation = new Operation(operation_name, operation_config);
- operation.set_ing_values(recipe_config[c].args);
- operation.set_breakpoint(recipe_config[c].breakpoint);
- operation.set_disabled(recipe_config[c].disabled);
- this.add_operation(operation);
- }
+Recipe.prototype._parse_config = function (recipe_config) {
+ for (let c = 0; c < recipe_config.length; c++) {
+ const operation_name = recipe_config[c].op;
+ const operation_config = OperationConfig[operation_name];
+ const operation = new Operation(operation_name, operation_config);
+ operation.set_ing_values(recipe_config[c].args);
+ operation.set_breakpoint(recipe_config[c].breakpoint);
+ operation.set_disabled(recipe_config[c].disabled);
+ this.add_operation(operation);
+ }
};
@@ -41,14 +41,14 @@ Recipe.prototype._parse_config = function(recipe_config) {
*
* @returns {*}
*/
-Recipe.prototype.get_config = function() {
- var recipe_config = [];
-
- for (var o = 0; o < this.op_list.length; o++) {
- recipe_config.push(this.op_list[o].get_config());
- }
-
- return recipe_config;
+Recipe.prototype.get_config = function () {
+ const recipe_config = [];
+
+ for (let o = 0; o < this.op_list.length; o++) {
+ recipe_config.push(this.op_list[o].get_config());
+ }
+
+ return recipe_config;
};
@@ -57,8 +57,8 @@ Recipe.prototype.get_config = function() {
*
* @param {Operation} operation
*/
-Recipe.prototype.add_operation = function(operation) {
- this.op_list.push(operation);
+Recipe.prototype.add_operation = function (operation) {
+ this.op_list.push(operation);
};
@@ -67,8 +67,8 @@ Recipe.prototype.add_operation = function(operation) {
*
* @param {Operation[]} operations
*/
-Recipe.prototype.add_operations = function(operations) {
- this.op_list = this.op_list.concat(operations);
+Recipe.prototype.add_operations = function (operations) {
+ this.op_list = this.op_list.concat(operations);
};
@@ -78,12 +78,12 @@ Recipe.prototype.add_operations = function(operations) {
* @param {number} position - The index of the Operation
* @param {boolean} value
*/
-Recipe.prototype.set_breakpoint = function(position, value) {
- try {
- this.op_list[position].set_breakpoint(value);
- } catch (err) {
+Recipe.prototype.set_breakpoint = function (position, value) {
+ try {
+ this.op_list[position].set_breakpoint(value);
+ } catch (err) {
// Ignore index error
- }
+ }
};
@@ -93,10 +93,10 @@ Recipe.prototype.set_breakpoint = function(position, value) {
*
* @param {number} pos
*/
-Recipe.prototype.remove_breaks_up_to = function(pos) {
- for (var i = 0; i < pos; i++) {
- this.op_list[i].set_breakpoint(false);
- }
+Recipe.prototype.remove_breaks_up_to = function (pos) {
+ for (let i = 0; i < pos; i++) {
+ this.op_list[i].set_breakpoint(false);
+ }
};
@@ -105,11 +105,11 @@ Recipe.prototype.remove_breaks_up_to = function(pos) {
*
* @returns {boolean}
*/
-Recipe.prototype.contains_flow_control = function() {
- for (var i = 0; i < this.op_list.length; i++) {
- if (this.op_list[i].is_flow_control()) return true;
- }
- return false;
+Recipe.prototype.contains_flow_control = function () {
+ for (let i = 0; i < this.op_list.length; i++) {
+ if (this.op_list[i].is_flow_control()) return true;
+ }
+ return false;
};
@@ -120,17 +120,17 @@ Recipe.prototype.contains_flow_control = function() {
* @param {number} [start_index=0] - The index to start searching from
* @returns (number}
*/
-Recipe.prototype.last_op_index = function(start_index) {
- var i = start_index + 1 || 0,
- op;
-
- for (; i < this.op_list.length; i++) {
- op = this.op_list[i];
- if (op.is_disabled()) return i-1;
- if (op.is_breakpoint()) return i-1;
- }
-
- return i-1;
+Recipe.prototype.last_op_index = function (start_index) {
+ let i = start_index + 1 || 0,
+ op;
+
+ for (; i < this.op_list.length; i++) {
+ op = this.op_list[i];
+ if (op.is_disabled()) return i - 1;
+ if (op.is_breakpoint()) return i - 1;
+ }
+
+ return i - 1;
};
@@ -141,56 +141,59 @@ Recipe.prototype.last_op_index = function(start_index) {
* @param {number} [start_from=0] - The index of the Operation to start executing from
* @returns {number} - The final progress through the recipe
*/
-Recipe.prototype.execute = function(dish, start_from) {
- start_from = start_from || 0;
- var op, input, output, num_jumps = 0;
-
- for (var i = start_from; i < this.op_list.length; i++) {
- op = this.op_list[i];
- if (op.is_disabled()) {
- continue;
- }
- if (op.is_breakpoint()) {
- return i;
- }
-
- try {
- input = dish.get(op.input_type);
-
- if (op.is_flow_control()) {
- // Package up the current state
- var state = {
- "progress" : i,
- "dish" : dish,
- "op_list" : this.op_list,
- "num_jumps" : num_jumps
- };
-
- state = op.run(state);
- i = state.progress;
- num_jumps = state.num_jumps;
- } else {
- output = op.run(input, op.get_ing_values());
- dish.set(output, op.output_type);
- }
- } catch (err) {
- var e = typeof err == "string" ? { message: err } : err;
+Recipe.prototype.execute = function (dish, start_from) {
+ start_from = start_from || 0;
+ let op,
+ input,
+ output,
+ num_jumps = 0;
- e.progress = i;
- e.display_str = op.name + " - ";
- if (e.fileName) {
- e.display_str += e.name + " in " + e.fileName +
- " on line " + e.lineNumber +
- "." + prettyPrintOne(Utils.escape_html(input), language, line_nums) + "";
- },
-
-
+ run_syntax_highlight(input, args) {
+ let language = args[0],
+ line_nums = args[1];
+ return `${prettyPrintOne(Utils.escape_html(input), language, line_nums)}`;
+ },
+
+
/**
* @constant
* @default
*/
- BEAUTIFY_INDENT: "\\t",
-
+ BEAUTIFY_INDENT: '\\t',
+
/**
* XML Beautify operation.
*
@@ -49,12 +49,12 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_xml_beautify: function(input, args) {
- var indent_str = args[0];
- return vkbeautify.xml(input, indent_str);
- },
-
-
+ run_xml_beautify(input, args) {
+ const indent_str = args[0];
+ return vkbeautify.xml(input, indent_str);
+ },
+
+
/**
* JSON Beautify operation.
*
@@ -62,12 +62,12 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_json_beautify: function(input, args) {
- var indent_str = args[0];
- return vkbeautify.json(input, indent_str);
- },
-
-
+ run_json_beautify(input, args) {
+ const indent_str = args[0];
+ return vkbeautify.json(input, indent_str);
+ },
+
+
/**
* CSS Beautify operation.
*
@@ -75,12 +75,12 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_css_beautify: function(input, args) {
- var indent_str = args[0];
- return vkbeautify.css(input, indent_str);
- },
-
-
+ run_css_beautify(input, args) {
+ const indent_str = args[0];
+ return vkbeautify.css(input, indent_str);
+ },
+
+
/**
* SQL Beautify operation.
*
@@ -88,18 +88,18 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_sql_beautify: function(input, args) {
- var indent_str = args[0];
- return vkbeautify.sql(input, indent_str);
- },
-
-
+ run_sql_beautify(input, args) {
+ const indent_str = args[0];
+ return vkbeautify.sql(input, indent_str);
+ },
+
+
/**
* @constant
* @default
*/
- PRESERVE_COMMENTS: false,
-
+ PRESERVE_COMMENTS: false,
+
/**
* XML Minify operation.
*
@@ -107,12 +107,12 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_xml_minify: function(input, args) {
- var preserve_comments = args[0];
- return vkbeautify.xmlmin(input, preserve_comments);
- },
-
-
+ run_xml_minify(input, args) {
+ const preserve_comments = args[0];
+ return vkbeautify.xmlmin(input, preserve_comments);
+ },
+
+
/**
* JSON Minify operation.
*
@@ -120,11 +120,11 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_json_minify: function(input, args) {
- return vkbeautify.jsonmin(input);
- },
-
-
+ run_json_minify(input, args) {
+ return vkbeautify.jsonmin(input);
+ },
+
+
/**
* CSS Minify operation.
*
@@ -132,12 +132,12 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_css_minify: function(input, args) {
- var preserve_comments = args[0];
- return vkbeautify.cssmin(input, preserve_comments);
- },
-
-
+ run_css_minify(input, args) {
+ const preserve_comments = args[0];
+ return vkbeautify.cssmin(input, preserve_comments);
+ },
+
+
/**
* SQL Minify operation.
*
@@ -145,11 +145,11 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_sql_minify: function(input, args) {
- return vkbeautify.sqlmin(input);
- },
-
-
+ run_sql_minify(input, args) {
+ return vkbeautify.sqlmin(input);
+ },
+
+
/**
* Generic Code Beautify operation.
*
@@ -158,10 +158,10 @@ var Code = {
* I'm not proud of this code, but seriously, try writing a generic lexer and parser that
* correctly generates an AST for multiple different languages. I have tried, and I can tell
* you it's pretty much impossible.
- *
+ *
* This basically works. That'll have to be good enough. It's not meant to produce working code,
* just slightly more readable code.
- *
+ *
* Things that don't work:
* - For loop formatting
* - Do-While loop formatting
@@ -173,133 +173,133 @@ var Code = {
* @param {Object[]} args
* @returns {string}
*/
- run_generic_beautify: function(input, args) {
- var code = input,
- t = 0,
- preserved_tokens = [],
- m;
-
+ run_generic_beautify(input, args) {
+ let code = input,
+ t = 0,
+ preserved_tokens = [],
+ m;
+
// Remove strings
- var sstrings = /'([^'\\]|\\.)*'/g;
- while (!!(m = sstrings.exec(code))) {
- code = preserve_token(code, m, t++);
- sstrings.lastIndex = m.index;
- }
-
- var dstrings = /"([^"\\]|\\.)*"/g;
- while (!!(m = dstrings.exec(code))) {
- code = preserve_token(code, m, t++);
- dstrings.lastIndex = m.index;
- }
-
+ const sstrings = /'([^'\\]|\\.)*'/g;
+ while (m = sstrings.exec(code)) {
+ code = preserve_token(code, m, t++);
+ sstrings.lastIndex = m.index;
+ }
+
+ const dstrings = /"([^"\\]|\\.)*"/g;
+ while (m = dstrings.exec(code)) {
+ code = preserve_token(code, m, t++);
+ dstrings.lastIndex = m.index;
+ }
+
// Remove comments
- var scomments = /\/\/[^\n\r]*/g;
- while (!!(m = scomments.exec(code))) {
- code = preserve_token(code, m, t++);
- scomments.lastIndex = m.index;
- }
-
- var mcomments = /\/\*[\s\S]*?\*\//gm;
- while (!!(m = mcomments.exec(code))) {
- code = preserve_token(code, m, t++);
- mcomments.lastIndex = m.index;
- }
-
- var hcomments = /(^|\n)#[^\n\r#]+/g;
- while (!!(m = hcomments.exec(code))) {
- code = preserve_token(code, m, t++);
- hcomments.lastIndex = m.index;
- }
-
+ const scomments = /\/\/[^\n\r]*/g;
+ while (m = scomments.exec(code)) {
+ code = preserve_token(code, m, t++);
+ scomments.lastIndex = m.index;
+ }
+
+ const mcomments = /\/\*[\s\S]*?\*\//gm;
+ while (m = mcomments.exec(code)) {
+ code = preserve_token(code, m, t++);
+ mcomments.lastIndex = m.index;
+ }
+
+ const hcomments = /(^|\n)#[^\n\r#]+/g;
+ while (m = hcomments.exec(code)) {
+ code = preserve_token(code, m, t++);
+ hcomments.lastIndex = m.index;
+ }
+
// Remove regexes
- var regexes = /\/.*?[^\\]\/[gim]{0,3}/gi;
- while (!!(m = regexes.exec(code))) {
- code = preserve_token(code, m, t++);
- regexes.lastIndex = m.index;
- }
-
+ const regexes = /\/.*?[^\\]\/[gim]{0,3}/gi;
+ while (m = regexes.exec(code)) {
+ code = preserve_token(code, m, t++);
+ regexes.lastIndex = m.index;
+ }
+
// Create newlines after ;
- code = code.replace(/;/g, ";\n");
-
+ code = code.replace(/;/g, ';\n');
+
// Create newlines after { and around }
- code = code.replace(/{/g, "{\n");
- code = code.replace(/}/g, "\n}\n");
-
+ code = code.replace(/{/g, '{\n');
+ code = code.replace(/}/g, '\n}\n');
+
// Remove carriage returns
- code = code.replace(/\r/g, "");
-
+ code = code.replace(/\r/g, '');
+
// Remove all indentation
- code = code.replace(/^\s+/g, "");
- code = code.replace(/\n\s+/g, "\n");
-
+ code = code.replace(/^\s+/g, '');
+ code = code.replace(/\n\s+/g, '\n');
+
// Remove trailing spaces
- code = code.replace(/\s*$/g, "");
-
+ code = code.replace(/\s*$/g, '');
+
// Remove newlines before {
- code = code.replace(/\n{/g, "{");
-
+ code = code.replace(/\n{/g, '{');
+
// Indent
- var i = 0,
- level = 0;
- while (i < code.length) {
- switch(code[i]) {
- case "{":
- level++;
- break;
- case "\n":
- if (i+1 >= code.length) break;
-
- if (code[i+1] == "}") level--;
- var indent = (level >= 0) ? Array(level*4+1).join(" ") : "";
-
- code = code.substring(0, i+1) + indent + code.substring(i+1);
- if (level > 0) i += level*4;
- break;
- }
- i++;
- }
+ let i = 0,
+ level = 0;
+ while (i < code.length) {
+ switch (code[i]) {
+ case '{':
+ level++;
+ break;
+ case '\n':
+ if (i + 1 >= code.length) break;
+
+ if (code[i + 1] == '}') level--;
+ var indent = (level >= 0) ? Array(level * 4 + 1).join(' ') : '';
+
+ code = code.substring(0, i + 1) + indent + code.substring(i + 1);
+ if (level > 0) i += level * 4;
+ break;
+ }
+ i++;
+ }
// Add strategic spaces
- code = code.replace(/\s*([!<>=+-/*]?)=\s*/g, " $1= ");
- code = code.replace(/\s*<([=]?)\s*/g, " <$1 ");
- code = code.replace(/\s*>([=]?)\s*/g, " >$1 ");
- code = code.replace(/([^+])\+([^+=])/g, "$1 + $2");
- code = code.replace(/([^-])-([^-=])/g, "$1 - $2");
- code = code.replace(/([^*])\*([^*=])/g, "$1 * $2");
- code = code.replace(/([^/])\/([^/=])/g, "$1 / $2");
- code = code.replace(/\s*,\s*/g, ", ");
- code = code.replace(/\s*{/g, " {");
- code = code.replace(/}\n/g, "}\n\n");
-
- // Just... don't look at this
- code = code.replace(/(if|for|while|with|elif|elseif)\s*\(([^\n]*)\)\s*\n([^{])/gim, "$1 ($2)\n $3");
- code = code.replace(/(if|for|while|with|elif|elseif)\s*\(([^\n]*)\)([^{])/gim, "$1 ($2) $3");
- code = code.replace(/else\s*\n([^{])/gim, "else\n $1");
- code = code.replace(/else\s+([^{])/gim, "else $1");
-
- // Remove strategic spaces
- code = code.replace(/\s+;/g, ";");
- code = code.replace(/\{\s+\}/g, "{}");
- code = code.replace(/\[\s+\]/g, "[]");
- code = code.replace(/}\s*(else|catch|except|finally|elif|elseif|else if)/gi, "} $1");
-
-
- // Replace preserved tokens
- var ptokens = /###preserved_token(\d+)###/g;
- while (!!(m = ptokens.exec(code))) {
- var ti = parseInt(m[1]);
- code = code.substring(0, m.index) + preserved_tokens[ti] + code.substring(m.index + m[0].length);
- ptokens.lastIndex = m.index;
- }
+ code = code.replace(/\s*([!<>=+-/*]?)=\s*/g, ' $1= ');
+ code = code.replace(/\s*<([=]?)\s*/g, ' <$1 ');
+ code = code.replace(/\s*>([=]?)\s*/g, ' >$1 ');
+ code = code.replace(/([^+])\+([^+=])/g, '$1 + $2');
+ code = code.replace(/([^-])-([^-=])/g, '$1 - $2');
+ code = code.replace(/([^*])\*([^*=])/g, '$1 * $2');
+ code = code.replace(/([^/])\/([^/=])/g, '$1 / $2');
+ code = code.replace(/\s*,\s*/g, ', ');
+ code = code.replace(/\s*{/g, ' {');
+ code = code.replace(/}\n/g, '}\n\n');
- return code;
-
- function preserve_token(str, match, t) {
- preserved_tokens[t] = match[0];
- return str.substring(0, match.index) +
- "###preserved_token" + t + "###" +
- str.substring(match.index + match[0].length);
- }
- },
+ // Just... don't look at this
+ code = code.replace(/(if|for|while|with|elif|elseif)\s*\(([^\n]*)\)\s*\n([^{])/gim, '$1 ($2)\n $3');
+ code = code.replace(/(if|for|while|with|elif|elseif)\s*\(([^\n]*)\)([^{])/gim, '$1 ($2) $3');
+ code = code.replace(/else\s*\n([^{])/gim, 'else\n $1');
+ code = code.replace(/else\s+([^{])/gim, 'else $1');
+
+ // Remove strategic spaces
+ code = code.replace(/\s+;/g, ';');
+ code = code.replace(/\{\s+\}/g, '{}');
+ code = code.replace(/\[\s+\]/g, '[]');
+ code = code.replace(/}\s*(else|catch|except|finally|elif|elseif|else if)/gi, '} $1');
+
+
+ // Replace preserved tokens
+ const ptokens = /###preserved_token(\d+)###/g;
+ while (m = ptokens.exec(code)) {
+ const ti = parseInt(m[1]);
+ code = code.substring(0, m.index) + preserved_tokens[ti] + code.substring(m.index + m[0].length);
+ ptokens.lastIndex = m.index;
+ }
+
+ return code;
+
+ function preserve_token(str, match, t) {
+ preserved_tokens[t] = match[0];
+ return `${str.substring(0, match.index)
+ }###preserved_token${t}###${
+ str.substring(match.index + match[0].length)}`;
+ }
+ },
};
diff --git a/src/js/operations/Compress.js b/src/js/operations/Compress.js
index b5d5de0f..9a7207e6 100755
--- a/src/js/operations/Compress.js
+++ b/src/js/operations/Compress.js
@@ -9,38 +9,38 @@
*
* @namespace
*/
-var Compress = {
+const Compress = {
/**
* @constant
* @default
*/
- COMPRESSION_TYPE: ["Dynamic Huffman Coding", "Fixed Huffman Coding", "None (Store)"],
+ COMPRESSION_TYPE: ['Dynamic Huffman Coding', 'Fixed Huffman Coding', 'None (Store)'],
/**
* @constant
* @default
*/
- INFLATE_BUFFER_TYPE: ["Adaptive", "Block"],
+ INFLATE_BUFFER_TYPE: ['Adaptive', 'Block'],
/**
* @constant
* @default
*/
- COMPRESSION_METHOD: ["Deflate", "None (Store)"],
+ COMPRESSION_METHOD: ['Deflate', 'None (Store)'],
/**
* @constant
* @default
*/
- OS: ["MSDOS", "Unix", "Macintosh"],
+ OS: ['MSDOS', 'Unix', 'Macintosh'],
/**
* @constant
* @default
*/
- RAW_COMPRESSION_TYPE_LOOKUP: {
- "Fixed Huffman Coding" : Zlib.RawDeflate.CompressionType.FIXED,
- "Dynamic Huffman Coding" : Zlib.RawDeflate.CompressionType.DYNAMIC,
- "None (Store)" : Zlib.RawDeflate.CompressionType.NONE,
- },
-
+ RAW_COMPRESSION_TYPE_LOOKUP: {
+ 'Fixed Huffman Coding': Zlib.RawDeflate.CompressionType.FIXED,
+ 'Dynamic Huffman Coding': Zlib.RawDeflate.CompressionType.DYNAMIC,
+ 'None (Store)': Zlib.RawDeflate.CompressionType.NONE,
+ },
+
/**
* Raw Deflate operation.
*
@@ -48,43 +48,43 @@ var Compress = {
* @param {Object[]} args
* @returns {byte_array}
*/
- run_raw_deflate: function(input, args) {
- var deflate = new Zlib.RawDeflate(input, {
- compressionType: Compress.RAW_COMPRESSION_TYPE_LOOKUP[args[0]]
- });
- return Array.prototype.slice.call(deflate.compress());
- },
-
-
+ run_raw_deflate(input, args) {
+ const deflate = new Zlib.RawDeflate(input, {
+ compressionType: Compress.RAW_COMPRESSION_TYPE_LOOKUP[args[0]],
+ });
+ return Array.prototype.slice.call(deflate.compress());
+ },
+
+
/**
* @constant
* @default
*/
- INFLATE_INDEX: 0,
+ INFLATE_INDEX: 0,
/**
* @constant
* @default
*/
- INFLATE_BUFFER_SIZE: 0,
+ INFLATE_BUFFER_SIZE: 0,
/**
* @constant
* @default
*/
- INFLATE_RESIZE: false,
+ INFLATE_RESIZE: false,
/**
* @constant
* @default
*/
- INFLATE_VERIFY: false,
+ INFLATE_VERIFY: false,
/**
* @constant
* @default
*/
- RAW_BUFFER_TYPE_LOOKUP: {
- "Adaptive" : Zlib.RawInflate.BufferType.ADAPTIVE,
- "Block" : Zlib.RawInflate.BufferType.BLOCK,
- },
-
+ RAW_BUFFER_TYPE_LOOKUP: {
+ Adaptive: Zlib.RawInflate.BufferType.ADAPTIVE,
+ Block: Zlib.RawInflate.BufferType.BLOCK,
+ },
+
/**
* Raw Inflate operation.
*
@@ -92,51 +92,51 @@ var Compress = {
* @param {Object[]} args
* @returns {byte_array}
*/
- run_raw_inflate: function(input, args) {
+ run_raw_inflate(input, args) {
// Deal with character encoding issues
- input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
- var inflate = new Zlib.RawInflate(input, {
- index: args[0],
- bufferSize: args[1],
- bufferType: Compress.RAW_BUFFER_TYPE_LOOKUP[args[2]],
- resize: args[3],
- verify: args[4]
- }),
- result = Array.prototype.slice.call(inflate.decompress());
-
+ input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
+ let inflate = new Zlib.RawInflate(input, {
+ index: args[0],
+ bufferSize: args[1],
+ bufferType: Compress.RAW_BUFFER_TYPE_LOOKUP[args[2]],
+ resize: args[3],
+ verify: args[4],
+ }),
+ result = Array.prototype.slice.call(inflate.decompress());
+
// Raw Inflate somethimes messes up and returns nonsense like this:
// ]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]...
// e.g. Input data of [8b, 1d, dc, 44]
// Look for the first two square brackets:
- if (result.length > 158 && result[0] == 93 && result[5] == 93) {
+ if (result.length > 158 && result[0] == 93 && result[5] == 93) {
// If the first two square brackets are there, check that the others
// are also there. If they are, throw an error. If not, continue.
- var valid = false;
- for (var i = 0; i < 155; i += 5) {
- if (result[i] != 93) {
- valid = true;
- }
- }
-
- if (!valid) {
- throw "Error: Unable to inflate data";
- }
+ let valid = false;
+ for (let i = 0; i < 155; i += 5) {
+ if (result[i] != 93) {
+ valid = true;
}
+ }
+
+ if (!valid) {
+ throw 'Error: Unable to inflate data';
+ }
+ }
// Trust me, this is the easiest way...
- return result;
- },
-
-
+ return result;
+ },
+
+
/**
* @constant
* @default
*/
- ZLIB_COMPRESSION_TYPE_LOOKUP: {
- "Fixed Huffman Coding" : Zlib.Deflate.CompressionType.FIXED,
- "Dynamic Huffman Coding" : Zlib.Deflate.CompressionType.DYNAMIC,
- "None (Store)" : Zlib.Deflate.CompressionType.NONE,
- },
-
+ ZLIB_COMPRESSION_TYPE_LOOKUP: {
+ 'Fixed Huffman Coding': Zlib.Deflate.CompressionType.FIXED,
+ 'Dynamic Huffman Coding': Zlib.Deflate.CompressionType.DYNAMIC,
+ 'None (Store)': Zlib.Deflate.CompressionType.NONE,
+ },
+
/**
* Zlib Deflate operation.
*
@@ -144,23 +144,23 @@ var Compress = {
* @param {Object[]} args
* @returns {byte_array}
*/
- run_zlib_deflate: function(input, args) {
- var deflate = new Zlib.Deflate(input, {
- compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]]
- });
- return Array.prototype.slice.call(deflate.compress());
- },
-
-
+ run_zlib_deflate(input, args) {
+ const deflate = new Zlib.Deflate(input, {
+ compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]],
+ });
+ return Array.prototype.slice.call(deflate.compress());
+ },
+
+
/**
* @constant
* @default
*/
- ZLIB_BUFFER_TYPE_LOOKUP: {
- "Adaptive" : Zlib.Inflate.BufferType.ADAPTIVE,
- "Block" : Zlib.Inflate.BufferType.BLOCK,
- },
-
+ ZLIB_BUFFER_TYPE_LOOKUP: {
+ Adaptive: Zlib.Inflate.BufferType.ADAPTIVE,
+ Block: Zlib.Inflate.BufferType.BLOCK,
+ },
+
/**
* Zlib Inflate operation.
*
@@ -168,26 +168,26 @@ var Compress = {
* @param {Object[]} args
* @returns {byte_array}
*/
- run_zlib_inflate: function(input, args) {
+ run_zlib_inflate(input, args) {
// Deal with character encoding issues
- input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
- var inflate = new Zlib.Inflate(input, {
- index: args[0],
- bufferSize: args[1],
- bufferType: Compress.ZLIB_BUFFER_TYPE_LOOKUP[args[2]],
- resize: args[3],
- verify: args[4]
- });
- return Array.prototype.slice.call(inflate.decompress());
- },
-
-
+ input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
+ const inflate = new Zlib.Inflate(input, {
+ index: args[0],
+ bufferSize: args[1],
+ bufferType: Compress.ZLIB_BUFFER_TYPE_LOOKUP[args[2]],
+ resize: args[3],
+ verify: args[4],
+ });
+ return Array.prototype.slice.call(inflate.decompress());
+ },
+
+
/**
* @constant
* @default
*/
- GZIP_CHECKSUM: false,
-
+ GZIP_CHECKSUM: false,
+
/**
* Gzip operation.
*
@@ -195,32 +195,32 @@ var Compress = {
* @param {Object[]} args
* @returns {byte_array}
*/
- run_gzip: function(input, args) {
- var filename = args[1],
- comment = args[2],
- options = {
- deflateOptions: {
- compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]]
- },
- flags: {
- fhcrc: args[3]
- }
- };
-
- if (filename.length) {
- options.flags.fname = true;
- options.filename = filename;
- }
- if (comment.length) {
- options.flags.fcommenct = true;
- options.comment = comment;
- }
-
- var gzip = new Zlib.Gzip(input, options);
- return Array.prototype.slice.call(gzip.compress());
- },
-
-
+ run_gzip(input, args) {
+ let filename = args[1],
+ comment = args[2],
+ options = {
+ deflateOptions: {
+ compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]],
+ },
+ flags: {
+ fhcrc: args[3],
+ },
+ };
+
+ if (filename.length) {
+ options.flags.fname = true;
+ options.filename = filename;
+ }
+ if (comment.length) {
+ options.flags.fcommenct = true;
+ options.comment = comment;
+ }
+
+ const gzip = new Zlib.Gzip(input, options);
+ return Array.prototype.slice.call(gzip.compress());
+ },
+
+
/**
* Gunzip operation.
*
@@ -228,37 +228,37 @@ var Compress = {
* @param {Object[]} args
* @returns {byte_array}
*/
- run_gunzip: function(input, args) {
+ run_gunzip(input, args) {
// Deal with character encoding issues
- input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
- var gunzip = new Zlib.Gunzip(input);
- return Array.prototype.slice.call(gunzip.decompress());
- },
-
-
+ input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
+ const gunzip = new Zlib.Gunzip(input);
+ return Array.prototype.slice.call(gunzip.decompress());
+ },
+
+
/**
* @constant
* @default
*/
- PKZIP_FILENAME: "file.txt",
+ PKZIP_FILENAME: 'file.txt',
/**
* @constant
* @default
*/
- ZIP_COMPRESSION_METHOD_LOOKUP: {
- "Deflate" : Zlib.Zip.CompressionMethod.DEFLATE,
- "None (Store)" : Zlib.Zip.CompressionMethod.STORE
- },
+ ZIP_COMPRESSION_METHOD_LOOKUP: {
+ Deflate: Zlib.Zip.CompressionMethod.DEFLATE,
+ 'None (Store)': Zlib.Zip.CompressionMethod.STORE,
+ },
/**
* @constant
* @default
*/
- ZIP_OS_LOOKUP: {
- "MSDOS" : Zlib.Zip.OperatingSystem.MSDOS,
- "Unix" : Zlib.Zip.OperatingSystem.UNIX,
- "Macintosh" : Zlib.Zip.OperatingSystem.MACINTOSH
- },
-
+ ZIP_OS_LOOKUP: {
+ MSDOS: Zlib.Zip.OperatingSystem.MSDOS,
+ Unix: Zlib.Zip.OperatingSystem.UNIX,
+ Macintosh: Zlib.Zip.OperatingSystem.MACINTOSH,
+ },
+
/**
* Zip operation.
*
@@ -266,32 +266,31 @@ var Compress = {
* @param {Object[]} args
* @returns {byte_array}
*/
- run_pkzip: function(input, args) {
- var password = Utils.str_to_byte_array(args[2]),
- options = {
- filename: Utils.str_to_byte_array(args[0]),
- comment: Utils.str_to_byte_array(args[1]),
- compressionMethod: Compress.ZIP_COMPRESSION_METHOD_LOOKUP[args[3]],
- os: Compress.ZIP_OS_LOOKUP[args[4]],
- deflateOption: {
- compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[5]]
- },
- },
- zip = new Zlib.Zip();
-
- if (password.length)
- zip.setPassword(password);
- zip.addFile(input, options);
- return Array.prototype.slice.call(zip.compress());
- },
-
-
+ run_pkzip(input, args) {
+ let password = Utils.str_to_byte_array(args[2]),
+ options = {
+ filename: Utils.str_to_byte_array(args[0]),
+ comment: Utils.str_to_byte_array(args[1]),
+ compressionMethod: Compress.ZIP_COMPRESSION_METHOD_LOOKUP[args[3]],
+ os: Compress.ZIP_OS_LOOKUP[args[4]],
+ deflateOption: {
+ compressionType: Compress.ZLIB_COMPRESSION_TYPE_LOOKUP[args[5]],
+ },
+ },
+ zip = new Zlib.Zip();
+
+ if (password.length) { zip.setPassword(password); }
+ zip.addFile(input, options);
+ return Array.prototype.slice.call(zip.compress());
+ },
+
+
/**
* @constant
* @default
*/
- PKUNZIP_VERIFY: false,
-
+ PKUNZIP_VERIFY: false,
+
/**
* Unzip operation.
*
@@ -299,36 +298,36 @@ var Compress = {
* @param {Object[]} args
* @returns {string}
*/
- run_pkunzip: function(input, args) {
- var options = {
- password: Utils.str_to_byte_array(args[0]),
- verify: args[1]
- },
- file = "",
- unzip = new Zlib.Unzip(input, options),
- filenames = unzip.getFilenames(),
- output = "