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
435cd2c8
Commit
435cd2c8
authored
Dec 19, 2014
by
Mark Garrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to get Markdown right
parent
f3c771a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
34 deletions
+42
-34
README.md
+42
-34
No files found.
README.md
View file @
435cd2c8
...
...
@@ -41,48 +41,56 @@ Usage
### Hash a password
```
php
use
ModDev\Password\Scrypt
;
:::php
$scrypt
=
new
Scrypt
();
$securePass
=
$scrypt
->
create
(
'user password'
);
```
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
\P
assword
\S
crypt;
$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
\P
assword
\S
crypt;
$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