forked from mirrors/easyappointments
Add max password length constant
This commit is contained in:
parent
63dbb51dec
commit
e3d3673ebf
2 changed files with 8 additions and 0 deletions
|
@ -79,6 +79,7 @@ define('TIME_FORMAT_REGULAR', 'regular');
|
||||||
define('TIME_FORMAT_MILITARY', 'military');
|
define('TIME_FORMAT_MILITARY', 'military');
|
||||||
|
|
||||||
define('MIN_PASSWORD_LENGTH', 7);
|
define('MIN_PASSWORD_LENGTH', 7);
|
||||||
|
define('MAX_PASSWORD_LENGTH', 100);
|
||||||
define('ANY_PROVIDER', 'any-provider');
|
define('ANY_PROVIDER', 'any-provider');
|
||||||
|
|
||||||
define('CALENDAR_VIEW_DEFAULT', 'default');
|
define('CALENDAR_VIEW_DEFAULT', 'default');
|
||||||
|
|
|
@ -22,9 +22,16 @@
|
||||||
* @param string $password Given string password.
|
* @param string $password Given string password.
|
||||||
*
|
*
|
||||||
* @return string Returns the hash string of the given password.
|
* @return string Returns the hash string of the given password.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function hash_password(string $salt, string $password): string
|
function hash_password(string $salt, string $password): string
|
||||||
{
|
{
|
||||||
|
if (strlen($password) > MAX_PASSWORD_LENGTH)
|
||||||
|
{
|
||||||
|
throw new Exception('The provided password is too long, please use a shorter value.');
|
||||||
|
}
|
||||||
|
|
||||||
$half = (int)(strlen($salt) / 2);
|
$half = (int)(strlen($salt) / 2);
|
||||||
|
|
||||||
$hash = hash('sha256', substr($salt, 0, $half) . $password . substr($salt, $half));
|
$hash = hash('sha256', substr($salt, 0, $half) . $password . substr($salt, $half));
|
||||||
|
|
Loading…
Reference in a new issue