mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
30c6917914
6 changed files with 25 additions and 18 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cyberchef",
|
"name": "cyberchef",
|
||||||
"version": "9.11.2",
|
"version": "9.11.5",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cyberchef",
|
"name": "cyberchef",
|
||||||
"version": "9.11.2",
|
"version": "9.11.5",
|
||||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||||
"author": "n1474335 <n1474335@gmail.com>",
|
"author": "n1474335 <n1474335@gmail.com>",
|
||||||
"homepage": "https://gchq.github.io/CyberChef",
|
"homepage": "https://gchq.github.io/CyberChef",
|
||||||
|
|
|
@ -156,7 +156,6 @@ export default class Stream {
|
||||||
|
|
||||||
// val is an array
|
// val is an array
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the skip forward table from the value to be searched.
|
* Builds the skip forward table from the value to be searched.
|
||||||
*
|
*
|
||||||
|
@ -173,9 +172,7 @@ export default class Stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
const length = val.length;
|
const length = val.length;
|
||||||
|
|
||||||
const initial = val[length-1];
|
const initial = val[length-1];
|
||||||
|
|
||||||
this.position = length;
|
this.position = length;
|
||||||
|
|
||||||
// Get the skip table.
|
// Get the skip table.
|
||||||
|
@ -183,7 +180,6 @@ export default class Stream {
|
||||||
let found = true;
|
let found = true;
|
||||||
|
|
||||||
while (this.position < this.length) {
|
while (this.position < this.length) {
|
||||||
|
|
||||||
// Until we hit the final element of val in the stream.
|
// Until we hit the final element of val in the stream.
|
||||||
while ((this.position < this.length) && (this.bytes[this.position++] !== initial));
|
while ((this.position < this.length) && (this.bytes[this.position++] !== initial));
|
||||||
|
|
||||||
|
@ -208,7 +204,7 @@ export default class Stream {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consume bytes if it matches the supplied value.
|
* Consume bytes if they match the supplied value.
|
||||||
*
|
*
|
||||||
* @param {Number} val
|
* @param {Number} val
|
||||||
*/
|
*/
|
||||||
|
@ -219,6 +215,7 @@ export default class Stream {
|
||||||
}
|
}
|
||||||
this.position++;
|
this.position++;
|
||||||
}
|
}
|
||||||
|
this.bitPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,15 +42,22 @@ class FromBase62 extends Operation {
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
if (input.length < 1) return [];
|
if (input.length < 1) return [];
|
||||||
const ALPHABET = Utils.expandAlphRange(args[0]).join("");
|
const alphabet = Utils.expandAlphRange(args[0]).join("");
|
||||||
const BN = BigNumber.clone({ ALPHABET });
|
const BN62 = BigNumber.clone({ ALPHABET: alphabet });
|
||||||
|
|
||||||
const re = new RegExp("[^" + ALPHABET.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
|
const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
|
||||||
input = input.replace(re, "");
|
input = input.replace(re, "");
|
||||||
|
|
||||||
const number = new BN(input, 62);
|
// Read number in using Base62 alphabet
|
||||||
|
const number = new BN62(input, 62);
|
||||||
|
// Copy to new BigNumber object that uses the default alphabet
|
||||||
|
const normalized = new BigNumber(number);
|
||||||
|
|
||||||
return Utils.convertToByteArray(number.toString(16), "Hex");
|
// Convert to hex and add leading 0 if required
|
||||||
|
let hex = normalized.toString(16);
|
||||||
|
if (hex.length % 2 !== 0) hex = "0" + hex;
|
||||||
|
|
||||||
|
return Utils.convertToByteArray(hex, "Hex");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation";
|
import Operation from "../Operation.mjs";
|
||||||
import OperationError from "../errors/OperationError";
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lorenz operation
|
* Lorenz operation
|
||||||
|
|
|
@ -44,12 +44,15 @@ class ToBase62 extends Operation {
|
||||||
input = new Uint8Array(input);
|
input = new Uint8Array(input);
|
||||||
if (input.length < 1) return "";
|
if (input.length < 1) return "";
|
||||||
|
|
||||||
const ALPHABET = Utils.expandAlphRange(args[0]).join("");
|
const alphabet = Utils.expandAlphRange(args[0]).join("");
|
||||||
const BN = BigNumber.clone({ ALPHABET });
|
const BN62 = BigNumber.clone({ ALPHABET: alphabet });
|
||||||
|
|
||||||
input = toHexFast(input).toUpperCase();
|
input = toHexFast(input).toUpperCase();
|
||||||
|
|
||||||
const number = new BN(input, 16);
|
// Read number in as hex using normal alphabet
|
||||||
|
const normalized = new BigNumber(input, 16);
|
||||||
|
// Copy to BigNumber clone that uses the specified Base62 alphabet
|
||||||
|
const number = new BN62(normalized);
|
||||||
|
|
||||||
return number.toString(62);
|
return number.toString(62);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue