You are here

private function XMLSecurityKey::encryptOpenSSL in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

Encrypts the given data (string) using the openssl-extension

Parameters

string $data:

Return value

string

Throws

Exception

1 call to XMLSecurityKey::encryptOpenSSL()
XMLSecurityKey::encryptData in src/XMLSecurityKey.php
Encrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.

File

src/XMLSecurityKey.php, line 423

Class

XMLSecurityKey

Namespace

Drupal\miniorange_saml

Code

private function encryptOpenSSL($data) {
  if ($this->cryptParams['type'] == 'public') {
    if (!openssl_public_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) {
      throw new Exception('Failure encrypting Data');
    }
  }
  else {
    if (!openssl_private_encrypt($data, $encrypted_data, $this->key, $this->cryptParams['padding'])) {
      throw new Exception('Failure encrypting Data');
    }
  }
  return $encrypted_data;
}