Noble base58check. Typed, native, 0-dep port of bs58check module.
npm install noble-base58checkBase58Check, a modified Base 58 binary-to-text encoding known as Base58Check is used for encoding Bitcoin addresses. More generically, Base58Check encoding is used for encoding byte arrays in Bitcoin into human-typable strings.
Port of bs58check module.
> noble-crypto — high-security, easily auditable set of contained cryptographic libraries and tools.
- No dependencies, one small file
- Easily auditable TypeScript/JS code
- Uses es2020 bigint. Supported in Chrome, Firefox, Safari, node 10+
- All releases are signed and trusted
- Check out all libraries:
secp256k1,
ed25519,
bls12-381,
ripemd160
Node:
```
npm install noble-base58check
`js
import * as b58c from "noble-base58check";
import { strictEqual } from "assert";
const hash = "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i";
(async () => {
const bytes = await b58c.decode(hash);
const sameHash = await b58c.encode(bytes);
strictEqual(sameHash, hash);
})();
`
Deno:
`typescript
import * as b58c from "https://deno.land/x/base58check/mod.ts";
import { assertEquals } from "https://deno.land/x/testing/asserts.ts";
const hash = "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i";
const bytes = await b58c.decode(hash);
const sameHash = await b58c.encode(bytes);
assertEquals(sameHash, hash);
`
Library: https://deno.land/x/base58check
- decode(string)
- encode(payload)
- decodeUnsafe(string)
- encodePlain(payload)
- decodePlain(string)
- decodePlainUnsafe(string)
- decodeRaw(buffer)
- getChecksum(buffer)
##### decode(string)
`typescript`
function decode(string: string): Promise
- string: string - string to decode with Base58CheckPromise
- Returns : decoded bytes
##### encode(payload)
`typescript`
function encode(payload: Uint8Array): Promise
- payload: Uint8Array - payload to encode with Base58CheckPromise
- Returns : encoded string
##### decodeUnsafe(string)
`typescript`
function decodeUnsafe(string: string): Promise
- string: string - string to decode with Base58CheckPromise
- Returns : Promise if success; otherwise Promise
##### decodePlain(string)
`typescript`
function decodePlain(string: string): Promise
- string: string - string to decode with plain Base58 (without check)Promise
- Returns : decoded bytes
##### encodePlain(payload)
`typescript`
function encodePlain(payload: Uint8Array): Promise
- payload: Uint8Array - payload to encode with plain Base58 (without check)Promise
- Returns : encoded string
##### decodePlainUnsafe(string)
`typescript`
function decodePlainUnsafe(string: string): Promise
- string: string - string to decode with plain Base58 (without check)Promise
- Returns : Promise if success; otherwise Promise
##### decodeRaw(buffer)
`typescript`
function decodeRaw(buffer: Uint8Array): Promise
- buffer: Uint8Array - payload to encode with plain Base58 (without check)Promise
- Returns : Promise payload without last 4 bytes if checksum valid; otherwise Promise
##### getChecksum(buffer)
`typescript`
function getChecksum(buffer: Uint8Array): Promise
- buffer: Uint8Array - payloadPromise
- Returns : checksum (double sha256)
- bs58check
- noble-crypto libraries by Paul Miller:
secp256k1,
ed25519,
bls12-381,
ripemd160
1. Clone the repository.
2. npm install to install build dependencies like TypeScriptnpm run compile
3. to compile TypeScript codenpm run test
4. to run jest on test/index.ts`
MIT (c) Serhii Pashchenko (https://serh11p.com), see LICENSE file.