sttr icon indicating copy to clipboard operation
sttr copied to clipboard

support crockford base32, Base-X base58, base62

Open coolaj86 opened this issue 2 years ago • 2 comments

The use case for Base32 is to provide something that's easier to write down and re-enter correctly - otherwise you'd always use base64. Base-N Base32 does not accomplish this. Crockford Base32 does (and another one I'm forgetting at the moment).

For this reason, the Base-N version of Base32 is rarely used. Almost always (survey other base32 libraries) it's Crockford Base32, which ensures that there are no ambiguous combinations - such as 0 and O, etc.

A few other bases that are popular in certain niches:

  • [ ] Crockford Base32
  • [ ] Base-X Base58 is used for cryptocurrency addresses and follows the same principles as Crockford Base32 in regards to character selection, but is also generic to arbitrary bit-widths (due to Base-X implementation)
    • [ ] Base58Check (the standard for how this is used in practice: Base58(Magic Bytes (Version) + Data + Checksum)
  • [ ] Base62 is used for prefixed & checksummed access tokens (e.g. GitHub, npm, Digital Ocean, etc)
    • [ ] Base62Check an informal name for actual way tokens are generated: Prefix + Base62(Entropy + Checksum)

coolaj86 avatar Mar 07 '23 18:03 coolaj86

Hello @coolaj86 thanks so much for you suggestion.

Sure i'm having a look at this, base62 looks like like a quick feature to add with dictionary

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Can you please provide little bit of details around entropy and entropy length

abhimanyu003 avatar Mar 08 '23 16:03 abhimanyu003

Re: base62: Can you please provide little bit of details around entropy and entropy length

By entropy I just mean "random bytes". Base62 isn't used in practice for data, just for tokens with a checksum, as described by:

  • https://github.com/therootcompany/base62-token.js
  • https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
  • https://github.blog/2021-09-23-announcing-npms-new-access-token-format/

This may be the most concise and descriptive section of it all: https://github.com/therootcompany/base62-token.js#github-token-breakdown

coolaj86 avatar Mar 15 '23 19:03 coolaj86