Skip to content

Instantly share code, notes, and snippets.

@stereobooster
Last active February 18, 2019 10:55
Show Gist options
  • Save stereobooster/a9a6543ae13c05a25eb1c417373adf09 to your computer and use it in GitHub Desktop.
Save stereobooster/a9a6543ae13c05a25eb1c417373adf09 to your computer and use it in GitHub Desktop.
// z85 alphabet - doesn't include ', ", \
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#";
const base = alphabet.length;
const base85 = input => {
const result = [];
do {
const remainder = input % base;
input = ~~(input / base);
result.push(alphabet[remainder]);
} while (input != 0);
return result.reverse().join("");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment