You are here

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

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 includes/XMLSecurityKey.php
Encrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.

File

includes/XMLSecurityKey.php, line 456

Class

XMLSecurityKey

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;
}