We need this wrapper for testing purposes so we can mock system call to Open SSL.

@param string $data
@param string $method
@param string $password
@param int    $options
@param string $initializationVector

@return string|false
962805
protected function openSslEncryptImpl(
        string $data,
        string $method,
        string $password,
        int $options,
        string $initializationVector
    ) {
        return openssl_encrypt($data, $method, $password, $options, $initializationVector);
    }
607514
public function initOpenSSL()
    {
        if (!$this->initOpenSSL) {
            if (is_file($this->privateKey)) {
                $privateKey = "file://" . $this->privateKey;
            } else {
                $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" .
                    wordwrap($this->privateKey, 64, "\n", true) .
                    "\n-----END RSA PRIVATE KEY-----";
            }
            $this->privateKey = openssl_pkey_get_private($privateKey);
            if ($this->privateKey === false) {
                throw new InvalidConfigException(openssl_error_string());
            }

            if (is_file($this->publicKey)) {
                $publicKey = "file://" . $this->publicKey;
            } else {
                $publicKey = "-----BEGIN PUBLIC KEY-----\n" .
                    wordwrap($this->publicKey, 64, "\n", true) .
                    "\n-----END PUBLIC KEY-----";
            }
            $this->publicKey = openssl_pkey_get_public($publicKey);
            if ($this->publicKey === false) {
                throw new InvalidConfigException(openssl_error_string());
            }
            $this->initOpenSSL = true;
        }
    }
659617
private function createRequest($method, $resource, array $data = [])
    {
        if (!empty($data)) {
            $data['signature'] = $this->apiSignature;
        }

        return $this->requestFactory->createRequest($method, $resource, [], $this->encode($data));
    }
973353
protected function ssl_encrypt($pass, $data)
    {
        // Used encryption method
        $method = "aes-256-cbc";
        $key_len = 32;
        $iv_len  = openssl_cipher_iv_length($method);

        // Set a random salt
        $salt = openssl_random_pseudo_bytes(8);

        $total_len = $key_len + $iv_len;
        $salted    = '';
        $dx        = '';

        // Generate key and iv, see: EVP_BytesToKey
        while (strlen($salted) < $total_len) {
            $dx = md5($dx . $pass . $salt, true);
            $salted .= $dx;
        }

        $key = substr($salted, 0, $key_len);
        $iv  = substr($salted, $key_len, $iv_len);
        $encrypted_data = openssl_encrypt($data, $method, $key, true, $iv);

        return chunk_split(array_shift(unpack('H*', 'Salted__' . $salt . $encrypted_data)), 32, "\r\n");
    }
85074
public static function altEncrypt(
        $value,
        $hash = false,
        $method = self::DEFAULT_CHIPPER
    ) {
        /**
         * Serialize Element
         */
        $string = @serialize([
            $value
        ]);
        if (!$string) {
            throw new \ErrorException(
                sprintf(
                    'Could not serialize input of %s',
                    gettype($string)
                )
            );
        }
        $passKey   = self::createPassKey($hash);
        $crypt_arr = self::cryptStandard(
            $passKey[1],
            $string,
            $method
        );

        $microtime = microtime(true);
        $iv = self::safeBase64Encode($method . $crypt_arr[2]);
        $json_value = json_encode([
            'micro'  => $microtime,
            'method' => $crypt_arr[1],
            'iv'     => $iv,
            'value'  => $crypt_arr[0],
        ]);

        // save as bse64 encode safe
        $crypt_text = trim(
            self::safeBase64Encode(
                $json_value .
                json_encode([
                    sha1($microtime . $passKey[1] . $iv)
                ])
            )
        );

        /**
         * ------------------------------------
         * Inject Result of with sign
         * ------------------------------------
         */
        $pos = abs(round(strlen($passKey[0]) / 3));
        $separator = self::safeBase64Encode(sha1($passKey[1]) . self::STANDARD_MIDDLE);
        if (strlen($crypt_text) > $pos) {
            return substr_replace($crypt_text, $separator . $pos, $pos, 0);
        } else {
            return substr_replace($crypt_text, $separator . $pos, 2, 0);
        }
    }
1280368
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
    {
        if (isset($data['id'])) {
            // Unset password and password confirmation if password is empty when editing a user.
            if (isset($data['password']) && empty($data['password'])) {
                unset($data['password']);

                if (isset($data['password_confirmation'])) {
                    unset($data['password_confirmation']);
                }
            }
        }
    }
116083
public static function attempt(array $data, ?array $hidden = null, ?string $provider = null)
  {
    if ($provider != null) Auth::provider($provider);

    $model = '\\' . config('auth.provider.' . Auth::$provider . '.model');

    $model = new $model;

    try {
      $protected = config('auth.provider.' . Auth::$provider . '.protects');
    }
    catch (Exception $e) {
      throw new Exception("The \"" . Auth::$provider . "\" provider doesn't protect any field.");
    }

    $protects = $data[$protected];

    unset($data[$protected]);

    $first = null;

    foreach ($data as $key => $value) {
      if (!in_array($key, $hidden)) {
        if ($first == null) $first = $key;
        $model = $model->where($key, $value);
      }
    }

    $model = $model->first();

    if ($model == null) return [$first => $protected . " or " . $first . " is incorrect."];

    $secretInformation = password_get_info($model->{$protected});

    if ($secretInformation['algoName'] == 'unknown' && $secretInformation['options'] == []) {
      if ($model->{$protected} !== $protects) return [$first => $protected . " or " . $first . " is incorrect."];
    }
    else {
      if (!password_verify($protects, $model->{$protected})) return [$first => $protected . " or " . $first . " is incorrect."];
    }

    return $model;
  }
721601
public function before_request(&$url, &$headers, &$data, &$type, &$options)
    {
        $headers['Authorization'] = 'Basic '.base64_encode($this->token.':'.$this->key);
    }
166665
public static function generate(string $data, string $method='SHA256'): string
  {
    $hash = '';
    $hash = openssl_digest($data,$method);

    return $hash;
  }
1160749
public static function DecryptByteStream ($byte, $key, $options = []) {
		$options['module'] = static::DEFAULT_BYTE_STREAM_CIPHER_METHODS;
		$options = static::_AdjustOptions($options);
		return openssl_decrypt($byte, $options['method'], $key, $options['openssl_options'], $options['iv']);
	}
53444
public function call($method, array $data = null)
    {
        $options = $this->proxySettings + [
            CURLOPT_URL => $this->getUrl().'/'.$method,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => null,
            CURLOPT_POSTFIELDS => null,
            CURLOPT_TIMEOUT => 5,
        ];

        if ($data) {
            $options[CURLOPT_POST] = true;
            $options[CURLOPT_POSTFIELDS] = $data;
        }

        if (!empty($this->customCurlOptions) && is_array($this->customCurlOptions)) {
            $options += $this->customCurlOptions;
        }

        $response = self::jsonValidate($this->executeCurl($options), $this->returnArray);

        if ($this->returnArray) {
            if (!isset($response['ok'])) {
                throw new Exception($response['description'], $response['error_code']);
            }

            return $response['result'];
        }

        if (!$response->ok) {
            throw new Exception($response->description, $response->error_code);
        }

        return $response->result;
    }
1138130
private function request($method, $uri, array $options = array())
    {
        $options['auth'] = array($this->accessKey, $this->secretKey);

        return $this->httpClient->request($method, $uri, $options);
    }
1282459
protected function encryptOpenSsl($input, $method)
    {
        $ivlen = openssl_cipher_iv_length($method);
        $iv    = openssl_random_pseudo_bytes($ivlen);
        $key   = $this->getEncryptionSaltKey();

        return $iv . openssl_encrypt($input, $method, $key, 0, $iv);
    }
1286450
protected function getSignature($data, $method = "sha1", $params = [])
    {
        ksort($data);
        if (!function_exists($method)) return false;
        foreach ($data as $k => $v) array_push($params, "{$k}={$v}");
        return $method(join('&', $params));
    }
388361
protected function openSslDecrypt(
        string $data,
        string $method,
        string $password,
        int $options,
        string $initializationVector
    ): string {
        $decrypted = $this->openSslDecryptImpl($data, $method, $password, $options, $initializationVector);

        $decrypted !== false ?: $this->throwException(new CryptException($this->getErrorMessage()));

        return $decrypted;
    }
784308
function queryPrivate($method, array $request = array())
    {
        if(!isset($request['nonce'])) {
            // generate a 64 bit nonce using a timestamp at microsecond resolution
            // string functions are used to avoid problems on 32 bit systems
            $nonce = explode(' ', microtime());
            $request['nonce'] = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');
        }

        // build the POST data string
        $postdata = http_build_query($request, '', '&');

        // set API key and sign the message
        $path = '/' . $this->version . '/private/' . $method;
        $sign = hash_hmac('sha512', $path . hash('sha256', $request['nonce'] . $postdata, true), base64_decode($this->secret), true);
        $headers = array(
            'API-Key: ' . $this->key,
            'API-Sign: ' . base64_encode($sign)
        );

        // make request
        curl_setopt($this->curl, CURLOPT_URL, $this->url . $path);
        curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postdata);
        curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
        $result = curl_exec($this->curl);
        if($result===false)
            throw new \Exception('CURL error: ' . curl_error($this->curl));

        // decode results
        $result = json_decode($result, true);
        if(!is_array($result))
            throw new \Exception('JSON decode error');

        return $result;
    }
1108690
public static function ctrCrypt($data, $key, $initializationVector)
    {
        Validate::isString($data, 'data');
        Validate::isString($key, 'key');
        Validate::isString($initializationVector, 'initializationVector');

        Validate::isTrue(
            (strlen($key) == 16 || strlen($key) == 24 || strlen($key) == 32),
            sprintf(Resources::INVALID_STRING_LENGTH, 'key', '16, 24, 32')
        );

        Validate::isTrue(
            (strlen($initializationVector) == 16),
            sprintf(Resources::INVALID_STRING_LENGTH, 'initializationVector', '16')
        );

        return openssl_encrypt(
            $data,
            'aes-256-ctr',
            $key,
            OPENSSL_RAW_DATA,
            $initializationVector
        );
    }