Added login function
This commit is contained in:
30
Core/Hash.php
Normal file
30
Core/Hash.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace Core;
|
||||
|
||||
class Hash
|
||||
{
|
||||
public static function make($string, $salt = '')
|
||||
{
|
||||
// return hash('sha256', $string . $salt);
|
||||
// return password_hash($string, PASSWORD_BCRYPT);
|
||||
return crypt($string, $salt);
|
||||
}
|
||||
|
||||
public static function salt()
|
||||
{
|
||||
// return mcrypt_create_iv($length);
|
||||
return uniqid(mt_rand());
|
||||
}
|
||||
|
||||
public static function unique()
|
||||
{
|
||||
return self::make(uniqid());
|
||||
}
|
||||
|
||||
public static function compare($string, $salt, $hash)
|
||||
{
|
||||
// return (Hash::make($string, $salt) === $hash) ? true : false;
|
||||
// return password_verify($string, $hash);
|
||||
return hash_equals($hash, Hash::make($string, $salt));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user