secret_length = 32; $options->algorithm = AuthenticatorInterface::ALGO_SHA512; $options->digits=6; $this->authenticator = new Authenticator($options); } /** * @brief build a secret key and returns it * @return string random string of 32 char */ function build_secret() { $secret = $this->authenticator->createSecret(); return $secret; } /** * @brief compute a code for auth. for the user passed in parameter * @param $secret (string) secret stored in AC_USER */ function compute_code($secret) { $this->authenticator->setSecret($secret); return $this->authenticator->code(); } public function get_authenticator() { return $this->authenticator; } public function set_authenticator($authenticator) { $this->authenticator = $authenticator; return $this; } }