Skip to content

Instantly share code, notes, and snippets.

@flockonus
Last active August 7, 2020 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flockonus/8e0db6d150aaf64ba060d19618c23cb1 to your computer and use it in GitHub Desktop.
Save flockonus/8e0db6d150aaf64ba060d19618c23cb1 to your computer and use it in GitHub Desktop.
//https://tools.ietf.org/id/draft-msporny-base58-01.html
// N=10, search space = 4e17
// N=18, search space = 5e31
function rand58(length) {
const base = ('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').split('')
return Array.call(null, length).fill(0).map(() => base[Math.floor(Math.random() * 1e9) % base.length]).join('')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment