2017 © Pedro PelĂĄez
 

library randomtoken

Random token generator with custom length

image

shox/randomtoken

Random token generator with custom length

  • Tuesday, December 27, 2016
  • by shox
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,444 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 20 % Grown

The README.md

RandomToken

RandomToken function

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)

RandomToken function with prefix

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)

Getting Started

Prerequisites

Composer is required, (*10)

Installing

composer require calshox/randomtoken

Examples

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

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details, (*19)

The Versions

27/12 2016

dev-master

9999999-dev https://github.com/calshox/RandomToken

Random token generator with custom length

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

token hash