forked from SaiyansKing/TibiaClientGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generatersa.php
53 lines (48 loc) · 1.7 KB
/
generatersa.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
<?php
function unfucked_base_convert($numstring, $frombase, $tobase)
{
$chars = "0123456789abcdefghijklmnopqrstuvwxyz";
$tostring = substr($chars, 0, $tobase);
$length = strlen($numstring);
$result = '';
for ($i = 0; $i < $length; $i++)
{
$number[$i] = strpos($chars, $numstring{$i});
}
do
{
$divide = 0;
$newlen = 0;
for ($i = 0; $i < $length; $i++)
{
$divide = $divide * $frombase + $number[$i];
if ($divide >= $tobase)
{
$number[$newlen++] = (int)($divide / $tobase);
$divide = $divide % $tobase;
} elseif ($newlen > 0)
{
$number[$newlen++] = 0;
}
}
$length = $newlen;
$result = $tostring{$divide} . $result;
} while ($newlen != 0);
return $result;
}
$config = array(
"config" => dirname(__FILE__) . '/openssl.cnf',
"private_key_bits" => 1024,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
);
$key = openssl_pkey_new($config);
openssl_pkey_export($key, $privatekey, null, $config);
$details = openssl_pkey_get_details($key);
openssl_pkey_free($key);
while(openssl_error_string() !== false) {}
$hex = array_map(bin2hex, $details['rsa']);
echo 'Client RSA Key:<br><textarea rows="10" cols="50">'.unfucked_base_convert($hex['n'], 16, 10).'</textarea><br>
Old Server RSA Key:<br><textarea rows="15" cols="50">const char* p("'.unfucked_base_convert($hex['p'], 16, 10).'");
const char* q("'.unfucked_base_convert($hex['q'], 16, 10).'");
const char* d("'.unfucked_base_convert($hex['d'], 16, 10).'");</textarea><br>
New Server RSA Key.pem<br><textarea rows="15" cols="50">'.$privatekey.'</textarea>';