Skip to content

Commit 41a9f50

Browse files
authored
Create encode.php
1 parent fa2c7ae commit 41a9f50

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

encode.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
// 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+
$data=[
10+
"status"=>"success",
11+
"data1"=>"test1",
12+
"data2"=>"test2",
13+
"data3"=>"test3",
14+
"data4"=>"test4",
15+
"data5"=>"test5",
16+
];
17+
$data = json_encode($data);
18+
$jwt = JWT::encode($data, $key, 'HS256');
19+
print $jwt."\n";
20+
21+
// plain text
22+
$data = "Hello, World!";
23+
$jwt = JWT::encode($data, $key, 'HS256');
24+
print $jwt."\n";

0 commit comments

Comments
 (0)