diff --git a/app/Services/Cipher/ARGON2I.php b/app/Services/Cipher/ARGON2I.php index 8ed91947..58202d11 100644 --- a/app/Services/Cipher/ARGON2I.php +++ b/app/Services/Cipher/ARGON2I.php @@ -4,12 +4,12 @@ namespace App\Services\Cipher; class ARGON2I extends BaseCipher { - public function hash($value, $salt = '') + public function hash($value, $salt = ''): string { return password_hash($value, PASSWORD_ARGON2I); } - public function verify($password, $hash, $salt = '') + public function verify($password, $hash, $salt = ''): bool { return password_verify($password, $hash); } diff --git a/app/Services/Cipher/BCRYPT.php b/app/Services/Cipher/BCRYPT.php index 7f9ec885..a2903698 100644 --- a/app/Services/Cipher/BCRYPT.php +++ b/app/Services/Cipher/BCRYPT.php @@ -4,12 +4,12 @@ namespace App\Services\Cipher; class BCRYPT extends BaseCipher { - public function hash($value, $salt = '') + public function hash($value, $salt = ''): string { return password_hash($value, PASSWORD_BCRYPT); } - public function verify($password, $hash, $salt = '') + public function verify($password, $hash, $salt = ''): bool { return password_verify($password, $hash); } diff --git a/app/Services/Cipher/BaseCipher.php b/app/Services/Cipher/BaseCipher.php index c2dedbbf..7c227709 100644 --- a/app/Services/Cipher/BaseCipher.php +++ b/app/Services/Cipher/BaseCipher.php @@ -2,19 +2,24 @@ namespace App\Services\Cipher; -abstract class BaseCipher implements EncryptInterface +abstract class BaseCipher { /** - * {@inheritdoc} + * Encrypt given string with given salt. + * + * @param string $value + * @param string $salt */ - public function hash($value, $salt = '') - { - } + public abstract function hash($value, $salt = ''); /** - * {@inheritdoc} + * Verify that the given hash matches the given password. + * + * @param string $password + * @param string $hash + * @param string $salt */ - public function verify($password, $hash, $salt = '') + public function verify($password, $hash, $salt = '') { return hash_equals($hash, $this->hash($password, $salt)); } diff --git a/app/Services/Cipher/EncryptInterface.php b/app/Services/Cipher/EncryptInterface.php deleted file mode 100644 index 32d30763..00000000 --- a/app/Services/Cipher/EncryptInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -