An open API service indexing awesome lists of open source software.

https://github.com/srph/jelai.php-hashing

jelai.php Hashing abstraction
https://github.com/srph/jelai.php-hashing

Last synced: about 1 month ago
JSON representation

jelai.php Hashing abstraction

Awesome Lists containing this project

README

          

# jelai.php-hashing

jelai.php Hashing abstraction

## What is jelai.php?

Please see this [gist](https://gist.github.com/srph/2e2d51d46dadfdbc38e3).

## Usage

The package provides a built-in for *md5*.

```php
require __DIR__ . '/path/to/src/SRPH/Jelai/Hashing/MD5Hasher.php';
$hasher = new SRPH\Jelai\Hashing\MD5Hasher;
$hasher->make('123'); // '202cb962ac59075b964b07152d234b70'
$hasher->check('123', '202cb962ac59075b964b07152d234b70') // true
```

The abstraction simply provides an interface (```HashingInterface```).

```php
app->bind('SRPH\Jelai\Hashing\HashingInterface', 'MyApp\Hashing\BycryptHasher');
}
}
```

\* *This hashing abstraction is mostly a mimic of Laravel's hashing abstraction.*

## API

#### ```HashingInterface```

The interface requires to have methods ```make``` and ```check```.

- ```make``` (```$value```, *```array```* ```$options```);

Hash the provided value.

```returns```: ```string``` (the hashed value).

- ```check``` (```$value```, ```$hashedValue```, *```array```* ```$options```)

Checks if the provided *value* and *hashed value* (```$hashedValue```) is equal.

```returns```: ```boolean``

\* *Check the example, [MD5Hasher](https://github.com/srph/jelai.php-hashing/blob/master/src/SRPH/Jelai/Hashing/MD5Hasher.php).*

## Acknowledgement

**jelai.php-hashing** © 2015+, Kier Borromeo (srph). **jelai.php** is released under the [MIT](mit-license.org) license.

> [srph.github.io](http://srph.github.io)  · 
> GitHub [@srph](https://github.com/srph)  · 
> Twitter [@_srph](https://twitter.com/_srph)