@gibme/base58 20.0.1 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -8
- package/dist/base58.min.js +1 -1
- package/dist/base58.min.js.map +1 -1
- package/package.json +17 -19
package/README.md
CHANGED
|
@@ -1,24 +1,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gibme/base58
|
|
2
|
+
|
|
3
|
+
A lightweight TypeScript Base58 encoding/decoding library with support for both standard Base58 and CryptoNote Base58 formats.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @gibme/base58
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @gibme/base58
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Requires Node.js >= 22**
|
|
2
18
|
|
|
3
19
|
## Documentation
|
|
4
20
|
|
|
5
|
-
[https://gibme-npm.github.io/base58/](https://gibme-npm.github.io/base58/)
|
|
21
|
+
Full API documentation is available at [https://gibme-npm.github.io/base58/](https://gibme-npm.github.io/base58/)
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
6
24
|
|
|
7
|
-
|
|
25
|
+
### Standard Base58
|
|
8
26
|
|
|
9
27
|
```typescript
|
|
10
28
|
import Base58 from '@gibme/base58';
|
|
11
29
|
|
|
30
|
+
// Encode from hex string
|
|
12
31
|
const encoded = Base58.encode('02c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cfeb05f9d2');
|
|
13
|
-
|
|
14
32
|
console.log(encoded);
|
|
33
|
+
// => 6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
|
|
15
34
|
|
|
16
|
-
|
|
35
|
+
// Encode from Buffer or Uint8Array
|
|
36
|
+
const encodedFromBuffer = Base58.encode(Buffer.from('deadbeef', 'hex'));
|
|
37
|
+
console.log(encodedFromBuffer);
|
|
17
38
|
|
|
39
|
+
// Decode back to Buffer
|
|
40
|
+
const decoded = Base58.decode(encoded);
|
|
18
41
|
console.log(decoded.toString('hex'));
|
|
19
42
|
```
|
|
20
43
|
|
|
21
|
-
|
|
44
|
+
### CryptoNote Base58
|
|
45
|
+
|
|
46
|
+
CryptoNote Base58 is a variant used by CryptoNote-based cryptocurrencies that encodes data in fixed-size blocks.
|
|
22
47
|
|
|
23
48
|
```typescript
|
|
24
49
|
import Base58 from '@gibme/base58';
|
|
@@ -26,10 +51,31 @@ import Base58 from '@gibme/base58';
|
|
|
26
51
|
const encoded = Base58.cn_encode(
|
|
27
52
|
'9df6ee01c179d13e2a0c52edd8b821e2d53d707e47ddcaaf696644a45563564c2934bd50' +
|
|
28
53
|
'a8faca00a94c5a4dcc3cf070898c2db6ff5990556d08f5a09c8787900dcecab3b77173c1');
|
|
29
|
-
|
|
30
54
|
console.log(encoded);
|
|
55
|
+
// => TRTLv2RUL7X82vLeXnFmF7cfhKJ6UeiJzJdWQf556DEb7tkVqDAs7FVVKQVqkZqY47Q1PFwne2jZNKEn1gEeTWrb3JxG7HaMU4Q
|
|
31
56
|
|
|
32
57
|
const decoded = Base58.cn_decode(encoded);
|
|
33
|
-
|
|
34
58
|
console.log(decoded.toString('hex'));
|
|
35
59
|
```
|
|
60
|
+
|
|
61
|
+
## API
|
|
62
|
+
|
|
63
|
+
### `Base58.encode(data: string | Uint8Array | Buffer): string`
|
|
64
|
+
|
|
65
|
+
Encodes the given data into a standard Base58 string. String input is treated as hex-encoded.
|
|
66
|
+
|
|
67
|
+
### `Base58.decode(encoded: string): Buffer`
|
|
68
|
+
|
|
69
|
+
Decodes a standard Base58 string back into a Buffer.
|
|
70
|
+
|
|
71
|
+
### `Base58.cn_encode(data: string | Uint8Array | Buffer): string`
|
|
72
|
+
|
|
73
|
+
Encodes the given data into a CryptoNote Base58 string. String input is treated as hex-encoded.
|
|
74
|
+
|
|
75
|
+
### `Base58.cn_decode(encoded: string): Buffer`
|
|
76
|
+
|
|
77
|
+
Decodes a CryptoNote Base58 string back into a Buffer.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT - See [LICENSE](LICENSE) for details.
|