1.0.15 • Published 3 years ago

@anzerr/base.util v1.0.15

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Intro

GitHub Actions status | linter GitHub Actions status | publish GitHub Actions status | test

base encoding / decoding of any given alphabet for bitcoin style leading zero compression and rfc4648

Install

npm install --save git+https://github.com/anzerr/base.util.git
npm install --save @anzerr/base.util

Example

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'))); // <Buffer 0c 19 17 16 1e 18 13 01 0e 08>

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
1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

4 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.1

6 years ago

1.0.2

6 years ago

1.0.3

6 years ago