1. Go to this page and download the library: Download stayallive/random-tokens 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/ */
stayallive / random-tokens example snippets
use Stayallive\RandomTokens\RandomToken;
// The prefix is ng)$token; // Outputs: prefix_ieJCRA8kOyyrzm4hoM2yVbnKDFMzqu2ZIDR0
echo $token->prefix; // Outputs: prefix
echo $token->random; // Outputs: ieJCRA8kOyyrzm4hoM2yVbnKDFMzqu
echo $token->checksum; // Outputs: 2ZIDR0
use Stayallive\RandomTokens\RandomToken;
// Construct a random token from a string, this will validate the token and throws an exception if it's invalid
try {
$token = RandomToken::fromString('prefix_ieJCRA8kOyyrzm4hoM2yVbnKDFMzqu2ZIDR0');
} catch (\Stayallive\RandomTokens\Exceptions\InvalidTokenFormatException) {
// Indicates the token is not in the expected format
} catch (\Stayallive\RandomTokens\Exceptions\InvalidTokenChecksumException) {
// Indicates the token does not have a valid checksum
} catch (\Stayallive\RandomTokens\Exceptions\InvalidTokenException) {
// Indicates the token is invalid for any of the reasons above
}
// If the token is valid you can extact the prefix, token and checksum for further validation
echo $token->prefix; // Outputs: prefix
echo $token->random; // Outputs: ieJCRA8kOyyrzm4hoM2yVbnKDFMzqu
echo $token->checksum; // Outputs: 2ZIDR0
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.