mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Fix Base58 handling of strings with only null characters
This commit is contained in:
parent
866c9a94ae
commit
4c6200f233
3 changed files with 28 additions and 10 deletions
|
@ -43,7 +43,7 @@ class ToBase58 extends Operation {
|
|||
run(input, args) {
|
||||
input = new Uint8Array(input);
|
||||
let alphabet = args[0] || ALPHABET_OPTIONS[0].value,
|
||||
result = [0];
|
||||
result = [];
|
||||
|
||||
alphabet = Utils.expandAlphRange(alphabet).join("");
|
||||
|
||||
|
@ -60,11 +60,9 @@ class ToBase58 extends Operation {
|
|||
}
|
||||
|
||||
input.forEach(function(b) {
|
||||
let carry = (result[0] << 8) + b;
|
||||
result[0] = carry % 58;
|
||||
carry = (carry / 58) | 0;
|
||||
let carry = b;
|
||||
|
||||
for (let i = 1; i < result.length; i++) {
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
carry += result[i] << 8;
|
||||
result[i] = carry % 58;
|
||||
carry = (carry / 58) | 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue