plaintext, $this->key); } function VerifyPassword($storedtext) { if(strpos($storedtext, "$2y$10") !== false) //standard bcrypt - used since 04/09/2020 return password_verify($this->plaintext, $storedtext); elseif(strpos($storedtext, "def50200") !== false) //argon2id w/ encryption - used since 26/02/2021 return \ParagonIE\PasswordLock\PasswordLock::decryptAndVerify($this->plaintext, $storedtext, $this->key); } function UpdatePassword($userId) { $pwhash = $this->createPassword(); db::run("UPDATE users SET password = :hash, lastpwdchange = UNIX_TIMESTAMP() WHERE id = :id", [":hash" => $pwhash, ":id" => $userId]); } function __construct($plaintext) { if(!class_exists('Defuse\Crypto\Key')) Polygon::ImportLibrary("PasswordLock"); $this->plaintext = $plaintext; $this->key = \Defuse\Crypto\Key::loadFromAsciiSafeString(SITE_CONFIG["keys"]["passwordEncryption"]); } }