-
Notifications
You must be signed in to change notification settings - Fork 6
/
bs58.ts
41 lines (34 loc) · 1.13 KB
/
bs58.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { base58 } from 'https://esm.sh/@scure/base@1.1.1';
import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers.ts';
const config = {
chars: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',
coder: base58,
ipfs: 'z',
type: 'base58'
};
/**
* @name base58Validate
* @summary Validates a base58 value.
* @description
* Validates that the supplied value is valid base58, throwing exceptions if not
*/
export const base58Validate = /*#__PURE__*/ createValidate(config);
/**
* @name base58Decode
* @summary Decodes a base58 value.
* @description
* From the provided input, decode the base58 and return the result as an `Uint8Array`.
*/
export const base58Decode = /*#__PURE__*/ createDecode(config, base58Validate);
/**
* @name base58Encode
* @summary Creates a base58 value.
* @description
* From the provided input, create the base58 and return the result as a string.
*/
export const base58Encode = /*#__PURE__*/ createEncode(config);
/**
* @name isBase58
* @description Checks if the input is in base58, returning true/false
*/
export const isBase58 = /*#__PURE__*/ createIs(base58Validate);