https://github.com/anzerr/base.util
base encoding / decoding of any given alphabet
https://github.com/anzerr/base.util
base base32 base58 node util
Last synced: 7 months ago
JSON representation
base encoding / decoding of any given alphabet
- Host: GitHub
- URL: https://github.com/anzerr/base.util
- Owner: anzerr
- License: mit
- Created: 2019-07-23T19:14:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-21T16:28:56.000Z (over 3 years ago)
- Last Synced: 2025-02-13T19:43:18.096Z (8 months ago)
- Topics: base, base32, base58, node, util
- Language: JavaScript
- Homepage:
- Size: 59.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### `Intro`


base encoding / decoding of any given alphabet for bitcoin style leading zero compression and [rfc4648](https://tools.ietf.org/html/rfc4648)
#### `Install`
``` bash
npm install --save git+https://github.com/anzerr/base.util.git
npm install --save @anzerr/base.util
```### `Example`
``` javascript
const {bc58, b32, Compress, Base} = require('base.util');const address = '003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187';
console.log(bc58.encode(Buffer.from(address, 'hex'), true)) // 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS
console.log(b32.encode(Buffer.from('foobar'), true)); // MZXW6YTBOI======
console.log(b32.encode(Buffer.from('foobar'))); //const base32 = (data, toString = true) => {
let handle = new Base('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', 40); // alphabet, pad size
return handle.encode(Buffer.from(data), toString);
}console.log(base32('fooba')) // MZXW6YTB
let bitcoin58 = new Compress('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
console.log(bc58.encode(Buffer.from(address, 'hex'), true)) // 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS
```