mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Tidied up Base45 ops
This commit is contained in:
parent
709b8696fc
commit
4f0b160ed3
4 changed files with 23 additions and 12 deletions
|
@ -29,7 +29,7 @@ class ToBase45 extends Operation {
|
|||
{
|
||||
name: "Alphabet",
|
||||
type: "string",
|
||||
value: "0-9A-Za-z"
|
||||
value: ALPHABET
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -44,6 +44,7 @@ class ToBase45 extends Operation {
|
|||
*/
|
||||
run(input, args) {
|
||||
input = new Uint8Array(input);
|
||||
const alphabet = Utils.expandAlphRange(args[0]);
|
||||
if (!input) return "";
|
||||
|
||||
const res = [];
|
||||
|
@ -57,7 +58,7 @@ class ToBase45 extends Operation {
|
|||
|
||||
let chars = 0;
|
||||
do {
|
||||
res.push(ALPHABET[b % 45]);
|
||||
res.push(alphabet[b % 45]);
|
||||
chars++;
|
||||
b = Math.floor(b / 45);
|
||||
} while (b > 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue