<?php
 class vB_Utility_Password_Algorithm_Argon2id extends vB_Utility_Password_Algorithm { private $options = []; protected function __construct($scheme) { if (!defined('PASSWORD_ARGON2ID')) { throw new vB_Utility_Password_Exception_SchemeNotSupported(); } $params = explode(':', $scheme); if (count($params) != 4) { throw new vB_Utility_Password_Exception_SchemeNotSupported(); } if ($params[1]) { $this->options['time_cost'] = (int) $params[1]; } if ($params[2]) { $this->options['memory_cost'] = (int) $params[2]; } if ($params[3]) { $this->options['threads'] = (int) $params[3]; } parent::__construct($scheme); } public function generateToken($password) { $hash = password_hash($password, PASSWORD_ARGON2ID, $this->options); return $hash; } public function verifyPassword($password, $token) { return password_verify($password, $token); } public function requireRehash($token) { return password_needs_rehash($token, PASSWORD_ARGON2ID, $this->options); } } 