Commit 43153316 by Mark Garrett

Merge branch 'release/0.2.1'

parents f3c771a2 6cb70eed
...@@ -41,48 +41,51 @@ Usage ...@@ -41,48 +41,51 @@ Usage
### Hash a password ### Hash a password
```php <?php
use ModDev\Password\Scrypt; use ModDev\Password\Scrypt;
$scrypt = new Scrypt(); $scrypt = new Scrypt();
$securePass = $scrypt->create('user password'); $securePass = $scrypt->create('user password');
```
### Check the hashed password against an user input ### Check the hashed password against an user input
```php <?php
use ModDev\Password\Scrypt; use ModDev\Password\Scrypt;
$scrypt = new Scrypt(); $scrypt = new Scrypt();
$securePass = 'the stored scrypt value'; $securePass = 'the stored scrypt value';
$password = 'the password to check'; $password = 'the password to check';
if ($scrypt->verify($password, $securePass)) { if ($scrypt->verify($password, $securePass)) {
echo "The password is correct! \n"; echo "The password is correct! \n";
} else { } else {
echo "The password is NOT correct.\n"; echo "The password is NOT correct.\n";
} }
```
### Optional Parameters ### Optional Parameters
```php <?php
use ModDev\Password\Scrypt; use ModDev\Password\Scrypt;
$scrypt = new Scrypt(array( $scrypt = new Scrypt(array(
'cpuDifficulty' => 16384, //The CPU difficulty. Also called "N" in scrypt documentation. Must be a power of 2. 'cpuDifficulty' => 16384, //The CPU difficulty. Also called "N" in scrypt documentation. Must be a power of 2.
'memoryDifficulty' => 8, //The memory difficulty. Also called "r" in scrypt documentation. 'memoryDifficulty' => 8, //The memory difficulty. Also called "r" in scrypt documentation.
'parallelDifficulty' => 1, //The parallel difficulty. Also called "p" in scrypt documentation. 'parallelDifficulty' => 1, //The parallel difficulty. Also called "p" in scrypt documentation.
'keyLength' => 32, //The key length. Must be greater or equal to 16. 'keyLength' => 32, //The key length. Must be greater or equal to 16.
)); ));
```
### Return the hash algorithm ### Return the hash algorithm
```php <?php
use ModDev\Password\Scrypt; use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
$passwordhashType = $scrypt->getHashType($hashedPassword);
$scrypt = new Scrypt(); ### Check if the password needs rehashing
$passwordhashType = $scrypt->getHashType($hashedPassword);
``` <?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
echo $scrypt->needsRehash($hashedPassword);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment