attla / data-token
Turn everything into a token: randomized or predictable.
dev-main
2022-08-14 17:37 UTC
Requires
- php: >=7.2.5
- attla/pincryp: dev-main
- hisorange/browser-detect: ^4.5.2
- nesbot/carbon: ^2.31
README
🪅 Turn everything into a token: randomized or predictable.
Installation
composer require attla/data-token
Usage
Creating and managing a token
use Attla\DataToken\Facade as DataToken; // Create with facade $token = DataToken::secrete('your secret phrase'); // Set the issuer claim $token->iss(); // Set the expiration in minutes $token->exp(120); // Set payload of the token $token->payload($model); // Set the browser identifier on token $token->bwr(); // Set user IP on the token $token->ip(); // Get the token $tokenEncoded = $token->encode();
Decoding the token
// Get token value as associative array $tokenValue = DataToken::decode($tokenEncoded, true); // Aliases for decode a token $tokenValue = DataToken::fromString($tokenEncoded); $tokenValue = DataToken::parseString($tokenEncoded); $tokenValue = DataToken::parse($tokenEncoded);
Others ways to make a token
// Make a unique token from anything $id = DataToken::id(123); // Make always the same token $sid = DataToken::sid(123); // Make a strong token $sign = DataToken::sign(123);
List of message methods
License
This package is licensed under the MIT license © Octha.