Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
427fe625
Commit
427fe625
authored
Jul 11, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor hash class to use PHPass.
parent
d2d5127f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
28 deletions
+22
-28
hash.php
system/hash.php
+22
-28
No files found.
system/hash.php
View file @
427fe625
...
...
@@ -3,48 +3,42 @@
class
Hash
{
/**
*
The salty, hashed value
.
*
Hash a string using PHPass
.
*
* @var string
*/
public
$value
;
/**
* The salt used during hashing.
* PHPass provides reliable bcrypt hashing, and is used by many popular PHP
* applications such as Wordpress and Joomla.
*
* @var string
* @access public
* @param string $value
* @return string
*/
public
$salt
;
public
static
function
make
(
$value
)
{
return
static
::
hasher
()
->
HashPassword
(
$value
);
}
/**
* Create a new salted hash instance.
*
* If no salt is provided, a random, 16 character salt will be generated
* to created the salted, hashed value. If a salt is provided, that salt
* will be used when hashing the value.
* Determine if an unhashed value matches a given hash.
*
* @param string $value
* @param string $
salt
* @return
void
* @param string $
hash
* @return
bool
*/
public
function
__construct
(
$value
,
$salt
=
null
)
public
static
function
check
(
$value
,
$hash
)
{
$this
->
salt
=
(
is_null
(
$salt
))
?
Str
::
random
(
16
)
:
$salt
;
$this
->
value
=
sha1
(
$value
.
$this
->
salt
);
return
static
::
hasher
()
->
CheckPassword
(
$value
,
$hash
);
}
/**
*
Factory for creating hash instances
.
*
Create a new PHPass instance
.
*
* @access public
* @param string $value
* @param string $salt
* @return Hash
* @return PasswordHash
*/
p
ublic
static
function
make
(
$value
,
$salt
=
null
)
p
rivate
static
function
hasher
(
)
{
return
new
self
(
$value
,
$salt
);
require_once
SYS_PATH
.
'vendor/phpass'
.
EXT
;
return
new
\PasswordHash
(
10
,
false
);
}
}
\ No newline at end of file
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