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 | */ |
||
27 | 72 | public static function encode(BufferInterface $buffer): string |
|
55 | |||
56 | /** |
||
57 | * Decode a base58 string |
||
58 | * @param string $base58 |
||
59 | * @return BufferInterface |
||
60 | * @throws Base58InvalidCharacter |
||
61 | */ |
||
62 | 103 | public static function decode(string $base58): BufferInterface |
|
87 | |||
88 | /** |
||
89 | * @param BufferInterface $data |
||
90 | * @return BufferInterface |
||
91 | */ |
||
92 | 102 | public static function checksum(BufferInterface $data): BufferInterface |
|
96 | |||
97 | /** |
||
98 | * Decode a base58 checksum string and validate checksum |
||
99 | * @param string $base58 |
||
100 | * @return BufferInterface |
||
101 | * @throws Base58ChecksumFailure |
||
102 | * @throws Base58InvalidCharacter |
||
103 | * @throws \Exception |
||
104 | */ |
||
105 | 89 | public static function decodeCheck(string $base58): BufferInterface |
|
122 | |||
123 | /** |
||
124 | * Encode the given data in base58, with a checksum to check integrity. |
||
125 | * |
||
126 | * @param BufferInterface $data |
||
127 | * @return string |
||
128 | */ |
||
129 | 59 | public static function encodeCheck(BufferInterface $data): string |
|
133 | } |
||
134 |