PHP code example of siranta / phptoken

1. Go to this page and download the library: Download siranta/phptoken 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/ */

    

siranta / phptoken example snippets


	use siranta\phptoken;
	
	$json = [
		"init" => time(),
		"exp" => time() + 60*10, // Token validity time
		"data" => [
			"id" => 12345678
		]
	];

	$key = "25d55ad283aa400af464c76d713c07ad"; // Private key
	$tt = new phptoken($json, $key);

	echo $tt->encode();

$token = new phptoken(TOKEN, KEY);
echo $token->decode();