Hello. We have to call a service, and we have to encrypt the request using a public key. We have an example of how to make the call in PHP. Also we have the public key and all the parameters that we need. The example in PHP is this (it uses openssl):

$url = "https://XXXXX/";
$json = '{"api_key":"XXXXX", "id":"1"}';
$jsonEncrypt, = '';
$publicKey = file_get_contents("public.key");
openssl_get_publickey($publicKey);
openssl_public_encrypt($json,  $jsonEncrypt,  $publicKey);
$jsonEncrypt = base64_encode($jsonEncrypt);

We need to do the same in Ensemble. I have tried to use this: > set IV = "" > set file = ##class(%FileCharacterStream).%New() > set file.Filename = "public.key" > set key = file.Read(file.Size) > set sc = **$System.Encryption.AESCBCEncryptStream**(json, .jsonEncrypt, key, IV) > if ($$$ISOK(sc)) { >         set jsonEncBase64 = **$System.Encryption.Base64Encode**(jsonEncrypt.Read(jsonEncrypt.Size)) > } But it doesn't work. The base64 that I get using this is not correctly encoded. Is this the way to encrypt using a public.key? How should I do it? Is there a way to use openssl\_public\_encrypt or something similar in Ensemble? Thank you very much in advance.