src/Authenticator.php
private function dispenseToken()
    {
        $token = bin2hex(random_bytes($this->config->getTokenLength())); // Generate token.

        $arr = array(
            'token' => $token,
            'expires' => time() + $this->config->getTokenTtl()
        ); // Prepare array containing token and expiry.

        $plain = Spyc::YAMLDump($arr); // Encode as YAML.
        $encrypted =  Encryption::encrypt($plain, $this->config->getSecretKey()); // Apply symmetric encryption.

        file_put_contents($this->config->getSessionFileName(), $encrypted); // Write to disk.

        return $token;
    }
private function dispenseToken()
    {
        $token = bin2hex(random_bytes($this->config->getTokenLength())); // Generate token.

        $arr = array(
            'token' => $token,
            'expires' => time() + $this->config->getTokenTtl()
        ); // Prepare array containing token and expiry.

        $plain = Spyc::YAMLDump($arr); // Encode as YAML.
        $encrypted =  Encryption::encrypt($plain, $this->config->getSecretKey()); // Apply symmetric encryption.

        file_put_contents($this->config->getSessionFileName(), $encrypted); // Write to disk.

        return $token;
    }
private function dispenseToken ( ) { $ token = bin2hex ( random_bytes ( $ this -> config -> getTokenLength ( ) ) ) ; // Generate token. $ arr = array ( 'token' => $ token , 'expires' => time ( ) + $ this -> config -> getTokenTtl ( ) ) ; // Prepare array containing token and expiry. $ plain = Spyc :: YAMLDump ( $ arr ) ; // Encode as YAML. $ encrypted = Encryption :: encrypt ( $ plain , $ this -> config -> getSecretKey ( ) ) ; // Apply symmetric encryption. file_put_contents ( $ this -> config -> getSessionFileName ( ) , $ encrypted ) ; // Write to disk. return $ token ; }
Dispenses a randomly generated authentication token.

@return string
Dispenses a randomly generated authentication token .