mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Fixed bug in Base62 operations when using different alphabets
This commit is contained in:
parent
d3473a7462
commit
cce84c3782
2 changed files with 18 additions and 8 deletions
|
@ -44,12 +44,15 @@ class ToBase62 extends Operation {
|
|||
input = new Uint8Array(input);
|
||||
if (input.length < 1) return "";
|
||||
|
||||
const ALPHABET = Utils.expandAlphRange(args[0]).join("");
|
||||
const BN = BigNumber.clone({ ALPHABET });
|
||||
const alphabet = Utils.expandAlphRange(args[0]).join("");
|
||||
const BN62 = BigNumber.clone({ ALPHABET: alphabet });
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue