diff options
Diffstat (limited to 'lib/private/Security')
-rw-r--r-- | lib/private/Security/Hasher.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/private/Security/Hasher.php b/lib/private/Security/Hasher.php index 22e850157fc..081cac51161 100644 --- a/lib/private/Security/Hasher.php +++ b/lib/private/Security/Hasher.php @@ -190,4 +190,18 @@ class Hasher implements IHasher { return $default; } + + public function validate(string $prefixedHash): bool { + $splitHash = $this->splitHash($prefixedHash); + if (empty($splitHash)) { + return false; + } + $validVersions = [3, 2, 1]; + $version = $splitHash['version']; + if (!in_array($version, $validVersions, true)) { + return false; + } + $algoName = password_get_info($splitHash['hash'])['algoName']; + return $algoName !== 'unknown'; + } } |