Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
scrypt-lib
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
onibi-composer
scrypt-lib
Commits
43153316
Commit
43153316
authored
Dec 19, 2014
by
Mark Garrett
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/0.2.1'
parents
f3c771a2
6cb70eed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
35 deletions
+38
-35
README.md
+38
-35
No files found.
README.md
View file @
43153316
...
...
@@ -41,48 +41,51 @@ Usage
### Hash a password
```
php
use
ModDev\Password\Scrypt
;
$scrypt
=
new
Scrypt
();
$securePass
=
$scrypt
->
create
(
'user password'
);
```
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
$securePass = $scrypt->create('user password');
### Check the hashed password against an user input
```
php
use
ModDev\Password\Scrypt
;
$scrypt
=
new
Scrypt
();
$securePass
=
'the stored scrypt value'
;
$password
=
'the password to check'
;
if
(
$scrypt
->
verify
(
$password
,
$securePass
))
{
echo
"The password is correct!
\n
"
;
}
else
{
echo
"The password is NOT correct.
\n
"
;
}
```
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
$securePass = 'the stored scrypt value';
$password = 'the password to check';
if ($scrypt->verify($password, $securePass)) {
echo "The password is correct! \n";
} else {
echo "The password is NOT correct.\n";
}
### Optional Parameters
```
php
use
ModDev\Password\Scrypt
;
$scrypt
=
new
Scrypt
(
array
(
'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.
'parallelDifficulty'
=>
1
,
//The parallel difficulty. Also called "p" in scrypt documentation.
'keyLength'
=>
32
,
//The key length. Must be greater or equal to 16.
));
```
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt(array(
'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.
'parallelDifficulty' => 1, //The parallel difficulty. Also called "p" in scrypt documentation.
'keyLength' => 32, //The key length. Must be greater or equal to 16.
));
### Return the hash algorithm
```
php
use
ModDev\Password\Scrypt
;
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
$passwordhashType = $scrypt->getHashType($hashedPassword);
$scrypt
=
new
Scrypt
();
$passwordhashType
=
$scrypt
->
getHashType
(
$hashedPassword
);
```
### Check if the password needs rehashing
<?php
use ModDev\Password\Scrypt;
$scrypt = new Scrypt();
echo $scrypt->needsRehash($hashedPassword);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment