-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy path002.phpt
34 lines (31 loc) · 790 Bytes
/
002.phpt
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
--TEST--
Check for jwt HMAC algorithm (HS256)
--SKIPIF--
<?php if (!extension_loaded("jwt")) print "skip"; ?>
--FILE--
<?php
$key = "example_key";
$payload = array(
"data" => [
"name" => "ZiHang Gao",
"admin" => true
],
"iss" => "http://example.org",
"sub" => "1234567890",
);
$token = jwt_encode($payload, $key);
echo $token . PHP_EOL;
print_r(jwt_decode($token, $key));
?>
--EXPECT--
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7Im5hbWUiOiJaaUhhbmcgR2FvIiwiYWRtaW4iOnRydWV9LCJpc3MiOiJodHRwOlwvXC9leGFtcGxlLm9yZyIsInN1YiI6IjEyMzQ1Njc4OTAifQ.6BafFmznKQOPVO9q5f5GgTVadITh2KmdUlJBF8UHOxo
Array
(
[data] => Array
(
[name] => ZiHang Gao
[admin] => 1
)
[iss] => http://example.org
[sub] => 1234567890
)