public static function hashAndEncrypt(string $password, Key $aesKey) : string
{
if (!\is_string($password)) {
throw new \InvalidArgumentException('Password must be a string.');
}
$hash = \password_hash(Base64::encode(\hash('sha384', $password, true)), PASSWORD_DEFAULT);
if ($hash === false) {
throw new \Exception("Unknown hashing error.");
}
return Crypto::encrypt($hash, $aesKey);
}