micro-base58

Fast and beautiful base58 encoder without dependencies.

Usage no npm install needed!

<script type="module">
  import microBase58 from 'https://cdn.skypack.dev/micro-base58';
</script>

README

micro-base58

Fast and beautiful base58 encoder without dependencies.

Deprecated. Switch to micro-base for audited version of base58 and others.


npm install micro-base58

Usage: base58(text[, alphabet]).

Included alphabets: ipfs/btc (default), xrp, xmr, flickr

First argument could be string, Buffer or UInt8Array.

const base58 = require('micro-base58');

base58('hello world'); // => 'StV1DL6CwTryKyV'
new Uint8Array(Array.from('hello world').map(c => c.charCodeAt(0))) // Browser
// => 'StV1DL6CwTryKyV'
base58('hello world', 'xrp'); // => 'StVrDLaUATiyKyV'

We don't include base58check because it requires sha256. You can implement it like this:

function base58check(array) {
  const checksum = sha256(sha256(array)).slice(0, 4);
  const data = new Uint8Array(array.length + 4);
  data.set(array);
  data.set(checksum, array.length)
  return base58(data);
}

License

MIT License (c) 2020, Paul Miller (https://paulmillr.com).

See LICENSE file.