1. Go to this page and download the library: Download risky-setiawan/sso-decoder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use RiskySetiawan\SSODecoder\JWTToken;
// Data payload
$payload = [
'user_id' => 123,
'email' => '[email protected]',
];
// Secret key (harus sama di semua aplikasi yang pakai package ini)
$secret = 'your-very-secret-key';
// Enkripsi payload jadi token terenkripsi (JWT + AES256)
// Function urldecode in payload is very important not change !
$encryptedToken = JWTToken::encrypt(urldecode($payload), $secret);
// Kirim $encryptedToken ke aplikasi lain, atau simpan di client
// Dekripsi token kembali ke payload array
$decryptedPayload = JWTToken::decrypt($encryptedToken, $secret);
print_r($decryptedPayload);
/*
Output:
[
'user_id' => 123,
'email' => '[email protected]',
]
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.