1 | <?php |
||
14 | class Base58 |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private static $base58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; |
||
20 | |||
21 | /** |
||
22 | * Encode a given hex string in base58 |
||
23 | * |
||
24 | * @param BufferInterface $buffer |
||
25 | * @return string |
||
26 | * @throws \Exception |
||
27 | */ |
||
28 | 63 | public static function encode(BufferInterface $buffer): string |
|
56 | |||
57 | /** |
||
58 | * Decode a base58 string |
||
59 | * @param string $base58 |
||
60 | * @return BufferInterface |
||
61 | * @throws Base58InvalidCharacter |
||
62 | */ |
||
63 | 86 | public static function decode(string $base58): BufferInterface |
|
89 | |||
90 | /** |
||
91 | * Calculate a checksum for the given data |
||
92 | * |
||
93 | * @param BufferInterface $data |
||
94 | * @return BufferInterface |
||
95 | */ |
||
96 | 79 | public static function checksum(BufferInterface $data): BufferInterface |
|
100 | |||
101 | /** |
||
102 | * Decode a base58 checksum string and validate checksum |
||
103 | * |
||
104 | * @param string $base58 |
||
105 | * @return BufferInterface |
||
106 | * @throws Base58ChecksumFailure |
||
107 | */ |
||
108 | 72 | public static function decodeCheck(string $base58): BufferInterface |
|
125 | |||
126 | /** |
||
127 | * Encode the given data in base58, with a checksum to check integrity. |
||
128 | * |
||
129 | * @param BufferInterface $data |
||
130 | * @return string |
||
131 | * @throws \Exception |
||
132 | */ |
||
133 | 50 | public static function encodeCheck(BufferInterface $data): string |
|
137 | } |
||
138 |