2017 © Pedro Peláez
 

library hash

Callable wrapper around PHP's password hashing and verification, optional with PSR3 Logger support

image

germania-kg/hash

Callable wrapper around PHP's password hashing and verification, optional with PSR3 Logger support

  • Wednesday, September 6, 2017
  • by germania-kg
  • Repository
  • 2 Watchers
  • 0 Stars
  • 42 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Germania KG • Hash Callables

Callable wrapper around PHP's password hashing and verification, optional with PSR3 Logger support, (*1)

Packagist PHP version Tests, (*2)

Installation with Composer

$ composer require germania-kg/hash
$ composer require germania-kg/hash:^2

PasswordHashCallable

This class wraps PHP's password_hash function in a callable class. It optionally accepts any PSR-3 Logger of which the debug method will be called each time it is invoked., (*3)

<?php
use Germania\Hash\PasswordHashCallable;

// Create Callable, optional with PSR-3 Logger
$hashing = new PasswordHashCallable;
$hashing = new PasswordHashCallable( $monolog );

// Get hashed value
echo $hashing( "mysecret" );

Configuration

You optionally may define cost and algo parameters for PHP's password_hash function. They default to 14 and \PASSWORD_BCRYPT respectively., (*4)

<?php
use Germania\Hash\PasswordHashCallable;

// Defaults
PasswordHashCallable::$cost = 14;
PasswordHashCallable::$algo = \PASSWORD_BCRYPT;

PasswordVerifyCallable

This class wraps PHP's password_verify function in a callable class. It optionally accepts any PSR-3 Logger of which the debug method will be called each time it is invoked., (*5)

<?php
use Germania\Hash\PasswordVerifyCallable;

// Create Callable, optional with PSR-3 Logger
$verifier = new PasswordVerifyCallable;
$verifier = new PasswordVerifyCallable( $monolog );

// Get hashed value
$secret = "foobar";
$hash   = password_hash($secret, \PASSWORD_BCRYPT);
$hash   = password_hash($secret, \PASSWORD_DEFAULT)

// Will be TRUE
echo $verifier( "foobar", $hash );

// Will be FALSE
echo $verifier( "wrong", $hash );

CallbackHashCallable

This class requires a custom callback (Callable or anonymous function). It optionally accepts any PSR-3 Logger of which the debug method will be called each time it is invoked., (*6)

<?php
use Germania\Hash\CallbackHashCallable;

// Create anonymous function
$callback = function( $token ) {
    return password_hash( $token );
};

// Create Callable, optional with PSR-3 Logger
$hashing = new CallbackHashCallable( $callback );
$hashing = new CallbackHashCallable( $callback, $monolog );

// Get hashed value
echo $hashing( "mysecret" );

Issues

See issues list., (*7)

Development

$ git clone https://github.com/GermaniaKG/Hash.git
$ cd Hash
$ composer install

Unit tests

Either copy phpunit.xml.dist to phpunit.xml and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:, (*8)

$ composer test
# or
$ vendor/bin/phpunit

The Versions

06/09 2017

dev-develop

dev-develop

Callable wrapper around PHP's password hashing and verification, optional with PSR3 Logger support

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Carsten Witt

psr-3 password callable psr3 hash verify

06/09 2017

dev-master

9999999-dev

Callable wrapper around PHP's password hashing and verification, optional with PSR3 Logger support

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Carsten Witt

psr-3 password callable psr3 hash verify

31/08 2017

1.1.4

1.1.4.0

Callable wrapper around PHP's password hashing and verification, optional with PSR3 Logger support

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Carsten Witt

psr-3 password callable psr3 hash verify

20/12 2016

1.1.3

1.1.3.0

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Carsten Witt

19/12 2016

1.1.2

1.1.2.0

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Carsten Witt

19/12 2016

1.1.1

1.1.1.0

  Sources   Download

MIT

The Requires

  • php ^5.5

 

The Development Requires

by Carsten Witt

02/11 2016

1.1.0

1.1.0.0

  Sources   Download

MIT

The Requires

  • php ^5.5

 

The Development Requires

by Carsten Witt

01/11 2016

1.0.1

1.0.1.0

  Sources   Download

MIT

The Development Requires

by Carsten Witt

31/10 2016

1.0.0

1.0.0.0

  Sources   Download

MIT

The Development Requires

by Carsten Witt