Last active
February 18, 2019 10:55
-
-
Save stereobooster/a9a6543ae13c05a25eb1c417373adf09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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