private function generateToken($expired = false)
    {
        $life = $this->tokenConfig['life'];

        if (!$expired) {
            $expire = time() + $life;
        } else {
            $expire = time() - ($life * 2);
        }

        $generator = new RandomGenerator();
        $tokenString = $generator->randomToken();

        $e = PasswordEncryptor::create_for_algorithm('blowfish'); //blowfish isn't URL safe and maybe too long?
        $salt = $e->salt($tokenString);
        $token = $e->encrypt($tokenString, $salt);

        return array(
            'token' => substr($token, 7),
            'expire' => $expire,
        );
    }
private function generateToken($expired = false)
    {
        $life = $this->tokenConfig['life'];

        if (!$expired) {
            $expire = time() + $life;
        } else {
            $expire = time() - ($life * 2);
        }

        $generator = new RandomGenerator();
        $tokenString = $generator->randomToken();

        $e = PasswordEncryptor::create_for_algorithm('blowfish'); //blowfish isn't URL safe and maybe too long?
        $salt = $e->salt($tokenString);
        $token = $e->encrypt($tokenString, $salt);

        return array(
            'token' => substr($token, 7),
            'expire' => $expire,
        );
    }
private function generateToken ( $ expired = false ) { $ life = $ this -> tokenConfig [ 'life' ] ; if ( ! $ expired ) { $ expire = time ( ) + $ life ; } else { $ expire = time ( ) - ( $ life * 2 ) ; } $ generator = new RandomGenerator ( ) ; $ tokenString = $ generator -> randomToken ( ) ; $ e = PasswordEncryptor :: create_for_algorithm ( 'blowfish' ) ; //blowfish isn't URL safe and maybe too long? $ salt = $ e -> salt ( $ tokenString ) ; $ token = $ e -> encrypt ( $ tokenString , $ salt ) ; return array ( 'token' => substr ( $ token , 7 ) , 'expire' => $ expire , ) ; }
Generates an encrypted random token
and an expiry date

@param  boolean $expired Set to true to generate an outdated token
@return array            token data array('token' => HASH, 'expire' => EXPIRY_DATE)
Generates an encrypted random token and an expiry date