mirror of
https://github.com/kvazar-network/crawler-api-node.git
synced 2025-01-09 06:37:57 +00:00
17 lines
396 B
PHP
17 lines
396 B
PHP
|
<?php
|
||
|
|
||
|
class Base58 {
|
||
|
|
||
|
const AVAILABLE_CHARS = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||
|
|
||
|
public static function encode($num, $length = 58): string {
|
||
|
|
||
|
return Crypto::dec2base($num, $length, self::AVAILABLE_CHARS);
|
||
|
}
|
||
|
|
||
|
public static function decode(string $addr, int $length = 58): string {
|
||
|
|
||
|
return Crypto::base2dec($addr, $length, self::AVAILABLE_CHARS);
|
||
|
}
|
||
|
}
|