Static init

@param string $key optional
@param string $secret optional

@return Patrol Can be either an empty Patrol object or key/secret combined based on parameters
971791
public static function init($key = null, $secret = null) {
        $patrol = new Patrol;

        if ($key && $secret) {
            $patrol->setApiKey($key);
            $patrol->setApiSecret($secret);
        }

        return $patrol;
    }
798275
public static function init($key = null)
    {
        $instance = Injector::inst()->get(__CLASS__);

        if (empty($key)) {
            user_error(
                'HybridSession::init() was not given a $key. Disabling cookie-based storage',
                E_USER_WARNING
            );
        } else {
            $instance->setKey($key);
        }

        session_set_save_handler($instance, true);

        self::$enabled = true;
    }
845345
public function parseRequest(Request $request, $secret, $dispatch = true)
    {
        if (!$this->checkSecurity($request, $secret)) {
            throw new \InvalidArgumentException('Invalid security checksum header.');
        }

        if ($className = $this->getEventClassName($this->eventName)) {
            $event = new $className($this->eventName, $this->payload, $this->delivery);
        } else {
            throw new \InvalidArgumentException('Unknown event type.');
        }

        if (null !== $this->eventDispatcher && $dispatch) {
            $this->eventDispatcher->dispatch(Events::WEBHOOK_REQUEST, $event);
        }

        return $event;
    }
591495
private static function makeRequest($key, $secret, $account)
    {
        $credentials = base64_encode($key . ':' . $secret);
        $endpoint = Core::instance()->getEndpoint(MPESA_AUTH, $account);

        return Core::instance()->client()->request('GET', $endpoint, [
            'headers' => [
                'Authorization' => 'Basic ' . $credentials,
                'Content-Type'  => 'application/json',
            ],
        ]);
    }
861920
public function hotp($secret, $counter)
    {
        if (!is_numeric($counter) || $counter < 0) {
            throw new \InvalidArgumentException('Invalid counter supplied');
        }
        
        $hash = hash_hmac(
                $this->algorithm,
                $this->getBinaryCounter($counter),
                $secret,
                true
        );
    
        return str_pad($this->truncate($hash), $this->digits, '0', STR_PAD_LEFT);
    }
905642
public static function set($error, $key = null)
    {
        if ($key) {
            static::$error[$key][] = $error;
        } else {
            static::$error[] = $error;
        }
    }
800533
public static function instance(string $key)
    {
        $collection = static::make();

        $class = $collection->get($key);

        if (class_exists($class)) {
            return resolve($class);
        }

        return null;
    }
398407
public function checkHotp($secret, $counter, $key)
    {
        return hash_equals($this->hotp($secret, $counter), $key);
    }
1062060
protected static function _signature($data, $secret = null) {
		unset($data['__signature']);
		$secret = ($secret) ?: static::$_secret;
		return hash_hmac('sha1', serialize($data), $secret);
	}
500530
public function setSecret(string $secret): Payload
    {
        $this->secret = hash_hmac('sha1', $this->rawData, $secret);

        return $this;
    }
849730
static function lock($string, $key = null) {
        return openssl_encrypt($string, self::_getSecMethod(), Utils::spare($key, self::_geteSecKey()), false, self::_getSecIv());
    }
134402
public function start(string $key)
    {
        $filteredKey = $this->filterKey($key);
        $value = $this->get($filteredKey);
        if ($value === null) {
            $this->lastKey = $filteredKey;
            ob_start();
        } else {
            $this->lastKey = null;
            trigger_error('Cache start failed');
        }
        return $this;
    }
1356278
function set_secret($secret = null)
    {
        // generate random hash and store in session
        if (!$secret) {
            if (!empty($_SESSION['auth_secret'])) {
                $secret = $_SESSION['auth_secret'];
            }
            else {
                $secret = rcube_utils::random_bytes(strlen($this->key));
            }
        }

        $_SESSION['auth_secret'] = $secret;
    }
378310
public static function generateToken($secret, $object)
    {
        try
        {
            return (new TokenGenerator($secret))
                            ->setData($object)
                            ->create();
        } catch (TokenException $e)
        {
            $e->getMessage();
            return false;
        }
    }
723459
private function setAuthentication($key, $secret, $call, $settings)
    {
        $isBasicAuth = $this->isBasicAuthentication($key, $secret);
        if ($isBasicAuth) {
            $this->apikey = $key;
            $this->apisecret = $secret;
        } else {
            $this->apitoken = $key;
            $this->version = Config::SMS_VERSION;
        }
        $this->initSettings($call, $settings);
        $this->setSettings();
    }
68066
public function setBitbucketOAuth($key, $secret, $domain = 'bitbucket.org')
    {
        $this->set(
            self::BITBUCKET_OAUTH_KEY . '/' . $this->escape($domain),
            ['consumer-key' => $key, 'consumer-secret' => $secret]
        );

        return $this;
    }
956699
public byte[] init(byte[] key){
		byte[] iv = new byte[blockSize];
		new SecureRandom().nextBytes(iv);
		init(iv, key);
		return iv;
	}