src/Api.php
public function decrypt($cypherText) {
    $envelope = json_decode(base64_decode($cypherText));

    if (!is_object($envelope) || empty($envelope->key) || empty($envelope->message)) {
      throw new EncryptionException('Encrypted message is not understood');
    }

    $key = base64_decode($envelope->key);
    $message = base64_decode($envelope->message);

    $decrypted = '';
    $result = openssl_open($message, $decrypted, $key, $this->getPublicKey());

    if ($result === FALSE) {
      throw new EncryptionException('Unable to decrypt a message: ' . openssl_error_string());
    }

    return json_decode($decrypted);
  }
public function decrypt($cypherText) {
    $envelope = json_decode(base64_decode($cypherText));

    if (!is_object($envelope) || empty($envelope->key) || empty($envelope->message)) {
      throw new EncryptionException('Encrypted message is not understood');
    }

    $key = base64_decode($envelope->key);
    $message = base64_decode($envelope->message);

    $decrypted = '';
    $result = openssl_open($message, $decrypted, $key, $this->getPublicKey());

    if ($result === FALSE) {
      throw new EncryptionException('Unable to decrypt a message: ' . openssl_error_string());
    }

    return json_decode($decrypted);
  }
public function decrypt ( $ cypherText ) { $ envelope = json_decode ( base64_decode ( $ cypherText ) ) ; if ( ! is_object ( $ envelope ) || empty ( $ envelope -> key ) || empty ( $ envelope -> message ) ) { throw new EncryptionException ( 'Encrypted message is not understood' ) ; } $ key = base64_decode ( $ envelope -> key ) ; $ message = base64_decode ( $ envelope -> message ) ; $ decrypted = '' ; $ result = openssl_open ( $ message , $ decrypted , $ key , $ this -> getPublicKey ( ) ) ; if ( $ result === FALSE ) { throw new EncryptionException ( 'Unable to decrypt a message: ' . openssl_error_string ( ) ) ; } return json_decode ( $ decrypted ) ; }
Decrypt a message which was encrypted with the Warden private key.

@param string $cypherText
The encrypted text
@return mixed
The original data

@throws EncryptionException
If there was a problem with the decryption process.
@throws WardenBadResponseException
If the response status from Warden was not 200 when retrieving the
public key.
Decrypt a message which was encrypted with the Warden private key .