Question:
Hello I try to use Delphi non activeX dll.
my actually task is to encrypt a binary document.
function TOmEncrypterPdf.DoEncrypt(data: RawUTF8; publickey: RawUTF8): Boolean;
var
encryptedStr: PWideChar;
key, str: PWideChar;
bytes: HCkByteData;
s: String;
begin
key := PWideChar(WideString(publickey));
str := PWideChar(WideString(data));
bytes := CkByteData_Create();
CkCrypt2_StringToBytes(cryptor, str, PWideChar('utf-8'), bytes);
CkRsa_ImportPublicKey(cryptor, key);
encryptedStr := CkRsa__encryptBytesENC(cryptor, bytes, False);
msg.Details.Document := encryptedStr;
end;
I try to get bytes array from my string but get AccessViolation exception:
CkCrypt2_StringToBytes(cryptor, str, PWideChar('utf-8'), bytes);
How to allocate bytes to write encrypted text into ?
Thanks.