forked from MikkelPaulson/smart-health-card-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.php
26 lines (21 loc) · 744 Bytes
/
parse.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
<?php
require_once(__DIR__.'/vendor/autoload.php');
use Jose\Component\Signature\Serializer\JWSSerializerManager;
use Jose\Component\Signature\Serializer\CompactSerializer;
$input_raw = file_get_contents('php://stdin');
$input_token = implode(
'',
array_map(
function ($ord) { return chr($ord + 45); },
str_split(preg_replace('/[^0-9]+/', '', $input_raw), 2)
)
);
$serializerManager = new JWSSerializerManager([
new CompactSerializer(),
]);
$jws = $serializerManager->unserialize($input_token);
echo "Header:\n";
echo json_encode($jws->getSignature(0)->getProtectedHeader(), JSON_PRETTY_PRINT);
echo "\n\nBody:\n";
echo json_encode(json_decode(gzinflate($jws->getPayload())), JSON_PRETTY_PRINT);
echo "\n";