Skip to content

Commit cb4c30f

Browse files
authored
Adding example
1 parent 02fcd6a commit cb4c30f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

decode.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
<?php
22
// https://github.com/BaseMax/php-jwt-example
3+
require 'vendor/autoload.php';
4+
use \Firebase\JWT\JWT;
5+
use \Firebase\JWT\SignatureInvalidException;
6+
$key = '83aeee518617ad6f3393bf0685e37d3e';
7+
8+
// JSON
9+
$token='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IntcInN0YXR1c1wiOlwic3VjY2Vzc1wiLFwiZGF0YTFcIjpcInRlc3QxXCIsXCJkYXRhMlwiOlwidGVzdDJcIixcImRhdGEzXCI6XCJ0ZXN0M1wiLFwiZGF0YTRcIjpcInRlc3Q0XCIsXCJkYXRhNVwiOlwidGVzdDVcIn0i.lTHo7zbetlA2su017EVukpSzL1Zj60k7mEZZHxAlz7k';
10+
$decode = JWT::decode($token, $key, array('HS256'));
11+
print $decode."\n";
12+
print json_decode($decode)."\n";
13+
14+
// plain text
15+
$token='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IkhlbGxvLCBXb3JsZCEi.XYtTUc2xhYATDmvY0cDzCREb-uplZf03Rq1sMFhweA4';
16+
$decode = JWT::decode($token, $key, array('HS256'));
17+
print $decode."\n";

0 commit comments

Comments
 (0)