Coder Social home page Coder Social logo

joanfabregat / secure-token-generator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 55 KB

Generate cryptographically secure alphanumeric tokens in PHP

Home Page: https://packagist.org/packages/joanfabregat/secure-token-generator

License: MIT License

PHP 100.00%

secure-token-generator's Introduction

Secure token generator

Latest Stable Version Total Downloads Latest Unstable Version License

Generate cryptographically secure alphanumeric tokens in PHP 8.2+ using PHP random_int() function.

Installation

The package is available on Packagist. The recommended way to install the library is through Composer:

composer require joanfabregat/secure-token-generator

Usage

use JoanFabregat\SecureTokenGenerator\SecureTokenGenerator;

// A simple token
$token = SecureTokenGenerator::generate(16);
echo $token; // will echo a 16 characters long alphanumeric token

// With all the options
$token = SecureTokenGenerator::generate(
    length: 32, 
    allowDigits: true, // 1234567890
    allowSpecialChars: true, // !@#$%^&*()_+{}|:"<>?[];',./
    allowUppercase: true, // ABCDEFGHIJKLMNOPQRSTUVWXYZ
    allowLowercase: true, // abcdefghijklmnopqrstuvwxyz
);
echo $token; // will echo a 32 characters long alphanumeric token with special characters

// An integer token
$token = SecureTokenGenerator::generateInt(6);
echo is_int($token); // will echo true
echo $token; // will echo a 6 digits long integer token (ie. 123456)

License

The library is published under the MIT license (see LICENSE file).

secure-token-generator's People

Contributors

joanfabregat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.