-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecrypt.php
80 lines (64 loc) · 1.46 KB
/
decrypt.php
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/php
<?php
$file = file_get_contents("image2");
$json =json_decode($file);
//print_r($json->outputs[0]);
foreach($json->outputs as $output) {
foreach($output->addresses as $address) {
//$hex = base58_decode($address);
//print_r($address);
//echo $hex ."\n";
//echo $address ."\n";
$base58 = decodeBase58($address);
$base58 = substr($base58,2) ."\n";
$base58 = substr($base58, 0, -9);
echo hexStringToByteString($base58);
//exit;
}
}
function decodeBase58($base58)
{
$origbase58=$base58;
$chars="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
$return="0";
for($i=0;$i<strlen($base58);$i++)
{
$current=(string)strpos($chars,$base58[$i]);
$return=(string)bcmul($return,"58",0);
$return=(string)bcadd($return,$current,0);
}
$return=encodeHex($return);
//leading zeros
for($i=0;$i<strlen($origbase58)&&$origbase58[$i]=="1";$i++)
{
$return="00".$return;
}
if(strlen($return)%2!=0)
{
$return="0".$return;
}
return $return;
}
function encodeHex($dec)
{
$chars="0123456789ABCDEF";
$return="";
while (bccomp($dec,0)==1)
{
$dv=(string)bcdiv($dec,"16",0);
$rem=(integer)bcmod($dec,"16");
$dec=$dv;
$return=$return.$chars[$rem];
}
return strrev($return);
}
function hexStringToByteString($hexString){
$len=strlen($hexString);
$byteString="";
for ($i=0;$i<$len;$i=$i+2){
$charnum=hexdec(substr($hexString,$i,2));
$byteString.=chr($charnum);
}
return $byteString;
}
?>