dev-master
9999999-dev https://github.com/calshox/RandomTokenRandom token generator with custom length
MIT
The Requires
- php >=5.3.0
token hash
Random token generator with custom length
Random token generator with custom length, (*1)
string RandomToken::generate(int $length [, int $mode = ALL [, string $alphabet = ""]])
$length
Length of the resulting string, (*2)
$mode
[CUSTOM, NUMERIC, LOWERCASE, UPPERCASE, NUMLOWER, NUMUPPER, ALL] Alphabet mode, (*3)
$alphabet
Custom Alphabet if mode = CUSTOM, (*4)
Random token generator with custom length and prefix, (*5)
string RandomToken::generatePrefix(string $prefix, int $length [, int $mode = ALL [, string $alphabet = ""]])
$prefix
Prefix, (*6)
$length
Length of the resulting string, (*7)
$mode
[CUSTOM, NUMERIC, LOWERCASE, UPPERCASE, NUMLOWER, NUMUPPER, ALL] Alphabet mode, (*8)
$alphabet
Custom Alphabet if mode = CUSTOM, (*9)
Composer is required, (*10)
composer require calshox/randomtoken
Generating a alphanumeric token [a-zA-Z0-9], (*11)
require_once __DIR__ . "/../vendor/autoload.php"; use Shox\RandomToken; echo RandomToken::generate(8); //f.ex: Fe3fLv5A
Only uppercase [A-Z], (*12)
echo RandomToken::generate(8, RandomToken::UPPERCASE); //f.ex: HRWEQERB
Only numeric [0-9], (*13)
echo RandomToken::generate(8, RandomToken::NUMERIC); //f.ex: 72468234
Only lowercase [a-z], (*14)
echo RandomToken::generate(8, RandomToken::LOWERCASE); //f.ex: felgncoi
Numeric and lowercase [a-z0-9], (*15)
echo RandomToken::generate(8, RandomToken::NUMLOWER); //f.ex: 9kid6gfb
Numeric and uppercase [a-z0-9], (*16)
echo RandomToken::generate(8, RandomToken::NUMUPPER); //f.ex: DYN7DP0X
Custom Alphabet, (*17)
echo RandomToken::generate(8, RandomToken::CUSTOM, "AEIOU0123456789"); //f.ex: E312AI7I
Only numeric with prefix [0-9], (*18)
echo RandomToken::generatePrefix("FX", 8, RandomToken::NUMERIC); //f.ex: FX72468234
This project is licensed under the MIT License - see the LICENSE.md file for details, (*19)
Random token generator with custom length
MIT
token hash