-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase58.php
More file actions
35 lines (25 loc) · 872 Bytes
/
base58.php
File metadata and controls
35 lines (25 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
use Symfony\Component\Uid\BinaryUtil;
require_once (__DIR__ . '/vendor/autoload.php');
$algos = implode("\n", hash_algos());
file_put_contents(__DIR__ . '/algos.txt', $algos);
$rawHash = hash('sha3-512', '', true);
$encodedHash = hash('sha3-512', '');
var_dump($rawHash);
var_dump($encodedHash);
$firstByte = $rawHash[0];
var_dump(base_convert(ord($firstByte), 10, 16));
echo PHP_EOL;
$strings = [
'',
' ',
'https://pursuit.purescript.org/packages/purescript-web3/0.18.2/docs/Network.Ethereum.Web3.Types.Types#t:HexString',
'http://solargeek.co/',
];
foreach ($strings as $string) {
$code = hash('sha3-512', $string, true);
$base64 = base64_encode($code);
$base58 = BinaryUtil::toBase($code, BinaryUtil::BASE58);
printf("%s - %d chars\n", $base64, strlen($base64));
printf("%s - %d chars\n", $base58, strlen($base58));
}