public static function generateKey()
    {
        do {
            $salt = sha1(time() . mt_rand());
            $newKey = substr($salt, 0, 40);
        } // Already in the DB? Fail. Try again
        while (self::keyExists($newKey));

        return $newKey;
    }
public static function generateKey()
    {
        do {
            $salt = sha1(time() . mt_rand());
            $newKey = substr($salt, 0, 40);
        } // Already in the DB? Fail. Try again
        while (self::keyExists($newKey));

        return $newKey;
    }
public static function generateKey ( ) { do { $ salt = sha1 ( time ( ) . mt_rand ( ) ) ; $ newKey = substr ( $ salt , 0 , 40 ) ; } // Already in the DB? Fail. Try again while ( self :: keyExists ( $ newKey ) ) ; return $ newKey ; }
A sure method to generate a unique API key

@return string
A sure method to generate a unique API key