Box_Password class created as a wrapper of password_* functions

This commit is contained in:
Vaidas Lungis committed 2014-11-13 13:23:53 +02:00
1 parent f7356cf1ad
commit bd96543709
1 file changed
+42
+42
View File
@@ -0,0 +1,42 @@
<?php
/**
* BoxBilling
*
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
* @license Apache-2.0
*
* Copyright BoxBilling, Inc
* This source file is subject to the Apache-2.0 License that is bundled
* with this source code in the file LICENSE
*/
class Box_Password {
private $algo = PASSWORD_DEFAULT;
private $options = array();
public function setAlgo ($algo)
{
$this->algo = $algo;
}
public function setOptions($options = array())
{
$this->options = $options;
}
public function hashIt($password)
{
return password_hash($password, $this->algo, $this->options);
}
public function verify ($password, $hash)
{
return password_verify((string) $password, $hash);
}
public function needsRehash($hash)
{
return password_needs_rehash($hash, $this->algo, $this->options);
}
}