1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of ocubom/base-convert |
5
|
|
|
* |
6
|
|
|
* © Oscar Cubo Medina <https://ocubom.github.io> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ocubom\Math\Base; |
13
|
|
|
|
14
|
|
|
use Ocubom\Math\AbstractBase; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* A base for Satoshi Nakamoto Base58 encoding. |
18
|
|
|
* |
19
|
|
|
* @see https://datatracker.ietf.org/doc/draft-msporny-base58/ |
20
|
|
|
* @see https://github.com/bitcoin/bitcoin/blob/master/src/base58.h |
21
|
|
|
*/ |
22
|
|
|
class Base58 extends AbstractBase |
23
|
|
|
{ |
24
|
|
|
const MAP = [ |
25
|
|
|
'' => '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz', |
26
|
|
|
1 => 0, 1, 2, 3, 4, 5, 6, 7, 8, 'A' => 9, |
27
|
|
|
'B' => 10, 'C' => 11, 'D' => 12, 'E' => 13, 'F' => 14, 'G' => 15, |
28
|
|
|
'H' => 16, 'J' => 17, 'K' => 18, 'L' => 19, 'M' => 20, 'N' => 21, |
29
|
|
|
'P' => 22, 'Q' => 23, 'R' => 24, 'S' => 25, 'T' => 26, 'U' => 27, |
30
|
|
|
'V' => 28, 'W' => 29, 'X' => 30, 'Y' => 31, 'Z' => 32, 'a' => 33, |
31
|
|
|
'b' => 34, 'c' => 35, 'd' => 36, 'e' => 37, 'f' => 38, 'g' => 39, |
32
|
|
|
'h' => 40, 'i' => 41, 'j' => 42, 'k' => 43, 'm' => 44, 'n' => 45, |
33
|
|
|
'o' => 46, 'p' => 47, 'q' => 48, 'r' => 49, 's' => 50, 't' => 51, |
34
|
|
|
'u' => 52, 'v' => 53, 'w' => 54, 'x' => 55, 'y' => 56, 'z' => 57, |
35
|
|
|
]; |
36
|
|
|
|
37
|
70 |
|
public function getMap(): array |
38
|
|
|
{ |
39
|
70 |
|
return self::MAP; |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|