2017 © Pedro Peláez
 

library signa

A framework agnostic token generator

image

nigelgreenway/signa

A framework agnostic token generator

  • Tuesday, April 12, 2016
  • by NigelGreenway
  • Repository
  • 1 Watchers
  • 0 Stars
  • 445 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 15 % Grown

The README.md

Signa

Latest Version on Packagist ![Software License][ico-license] Build Status ![Total Downloads][ico-downloads], (*1)

A framework agnostic token generator built for PHP 7. Uses scalar type hinting and return type hinting., (*2)

Will generate a secure token using hash_hmac with access to the value and the expiry date of that token for use within your storage. An insecure token can also be generated with access to just a value, useful for a CSRF token., (*3)

Install

Via Composer, (*4)

``` bash $ composer require nigelgreenway/signa, (*5)


## Usage ```php <?php require __DIR__.'/vendor/autoload.php'; $tokenGenerator = new \Signa\TokenGenerator('s0m3-s3cur3-k3y'); $tokenWithExpiry = $tokenGenerator->tokenWithExpiry( [ 'user_name' => 'Scooby Doo', 'age' => 7, ], new \DateTimeImmutable('+30 Days'), 'sha256' ); // A secure token, for password resets and such echo "A secure token\n"; echo sprintf("Value: %s\n", $tokenWithExpiry->value()); // Some hash string echo sprintf("Expires on: %s\n", $tokenWithExpiry->expiresOn()->format('Y-m-d H:i:s')); // 30 days from today, aka the future // An insecure token, generally CSRF and such echo "\nAn insecure token\n"; $insecureToken = $tokenGenerator->token(36); echo sprintf("Value: %s (Length %d)\n", $insecureToken->value(), strlen($insecureToken->value())); // Some string, 36 char length echo "\nAn insecure token with odd value\n"; $insecureToken = $tokenGenerator->token(33); echo sprintf("Value: %s (Length: %d)\n", $insecureToken->value(), strlen($insecureToken->value())); // Some string, 33 char length

Change log

Please see CHANGELOG for more information what has changed recently., (*6)

Testing

bash $ composer test, (*7)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*8)

Security

If you discover any security related issues, please email github@futurepixels.co.uk instead of using the issue tracker., (*9)

Credits

License

The MIT License (MIT). Please see License File for more information., (*10)

The Versions

12/04 2016

dev-master

9999999-dev

A framework agnostic token generator

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

12/04 2016

1.0.0

1.0.0.0

A framework agnostic token generator

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

12/04 2016

dev-development

dev-development

A framework agnostic token generator

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires