]> git.mxchange.org Git - friendica.git/blob - mod/modexp.php
Merge branch 'develop' into rewrites/dbm_is_result
[friendica.git] / mod / modexp.php
1 <?php
2
3 require_once('library/asn1.php');
4
5 function modexp_init(App &$a) {
6
7         if($a->argc != 2)
8                 killme();
9
10         $nick = $a->argv[1];
11         $r = q("SELECT `spubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
12                         dbesc($nick)
13         );
14
15         if (! dbm::is_result($r)) {
16                 killme();
17         }
18
19         $lines = explode("\n",$r[0]['spubkey']);
20         unset($lines[0]);
21         unset($lines[count($lines)]);
22         $x = base64_decode(implode('',$lines));
23
24         $r = ASN_BASE::parseASNString($x);
25
26         $m = $r[0]->asnData[1]->asnData[0]->asnData[0]->asnData;
27         $e = $r[0]->asnData[1]->asnData[0]->asnData[1]->asnData;
28
29         header("Content-type: application/magic-public-key");
30         echo 'RSA' . '.' . $m . '.' . $e ;
31
32         killme();
33
34 }
35