From d7395d7d8b279fbd25fd83bcc92d5114e637b6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Lundb=C3=B8l?= Date: Wed, 15 Nov 2017 18:31:38 +0100 Subject: [PATCH] Added info method to hashing component. --- src/Illuminate/Contracts/Hashing/Hasher.php | 8 ++++++++ src/Illuminate/Hashing/ArgonHasher.php | 12 ++++++++++++ src/Illuminate/Hashing/BcryptHasher.php | 12 ++++++++++++ src/Illuminate/Hashing/HashManager.php | 5 +++++ 4 files changed, 37 insertions(+) diff --git a/src/Illuminate/Contracts/Hashing/Hasher.php b/src/Illuminate/Contracts/Hashing/Hasher.php index 3310136e52bc..93c6fae5821a 100644 --- a/src/Illuminate/Contracts/Hashing/Hasher.php +++ b/src/Illuminate/Contracts/Hashing/Hasher.php @@ -31,4 +31,12 @@ public function check($value, $hashedValue, array $options = []); * @return bool */ public function needsRehash($hashedValue, array $options = []); + + /** + * Get info about the current hashedValue. + * + * @param string $hashedValue + * @return array + */ + public function info($hashedValue); } diff --git a/src/Illuminate/Hashing/ArgonHasher.php b/src/Illuminate/Hashing/ArgonHasher.php index f6a4718c8f6a..05d796a5dea0 100644 --- a/src/Illuminate/Hashing/ArgonHasher.php +++ b/src/Illuminate/Hashing/ArgonHasher.php @@ -157,4 +157,16 @@ protected function processors($options) { return $options['processors'] ?? $this->processors; } + + /** + * Get info about the current hashedValue. + * + * @param string $hashedValue + * + * @return array + */ + public function info($hashedValue) + { + return password_get_info($hashedValue); + } } diff --git a/src/Illuminate/Hashing/BcryptHasher.php b/src/Illuminate/Hashing/BcryptHasher.php index 333d8bf01118..d1bf86622308 100755 --- a/src/Illuminate/Hashing/BcryptHasher.php +++ b/src/Illuminate/Hashing/BcryptHasher.php @@ -90,4 +90,16 @@ protected function cost(array $options = []) { return $options['rounds'] ?? $this->rounds; } + + /** + * Get info about the current hashedValue. + * + * @param string $hashedValue + * + * @return array + */ + public function info($hashedValue) + { + return password_get_info($hashedValue); + } } diff --git a/src/Illuminate/Hashing/HashManager.php b/src/Illuminate/Hashing/HashManager.php index 49c50407cd41..aafd9b2462a6 100644 --- a/src/Illuminate/Hashing/HashManager.php +++ b/src/Illuminate/Hashing/HashManager.php @@ -64,6 +64,11 @@ public function needsRehash($hashedValue, array $options = []) return $this->driver()->needsRehash($hashedValue, $options); } + public function info($hashedValue) + { + return $this->driver()->info($hashedValue); + } + /** * Get the default driver name. *