Closed rafaelaznar closed 7 months ago
It would just be a matter of replacing the characters. For example:
BigNumber.set({
ALPHABET: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
});
const bigNumberToBase64 = big => big.toString(64).
replace(/\$/g, '+').replace(/_/g, '-');
const bigNumberFromBase64 = str => new BigNumber(
str.replace(/\+/g, '$').replace(/\-/g, '_'), 64);
console.log(
bigNumberToBase64(bigNumberFromBase64('+123abcZ+--'))
);
// '+123abcZ+--'
Can't convert to Base64 beacuse in Alphabet in B64 contains symbols that can't pass the condition
/^.$|[+-.\s]|(.).*\1/
givingAny workaround?