Sample code for 30+ languages & platforms
Delphi DLL

Example: Crypt2.EncryptEncoded method

Demonstrates how to call the EncryptEncoded method.

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Crypt2;

...

procedure TForm1.Button1Click(Sender: TObject);
var
crypt: HCkCrypt2;
encrypted: PWideChar;
decrypted: PWideChar;

begin
crypt := CkCrypt2_Create();

CkCrypt2_putCryptAlgorithm(crypt,'aes');
CkCrypt2_putCipherMode(crypt,'cbc');
CkCrypt2_putKeyLength(crypt,128);
CkCrypt2_SetEncodedKey(crypt,'000102030405060708090A0B0C0D0E0F','hex');
CkCrypt2_SetEncodedIV(crypt,'000102030405060708090A0B0C0D0E0F','hex');

// Encrypt the bytes 0x00, 0x01, 0x02, ... 0x0A
// and return the encrypted bytes using the lowercase hex encoding.
CkCrypt2_putEncodingMode(crypt,'hex_lower');
encrypted := CkCrypt2__encryptEncoded(crypt,'000102030405060708090a');
Memo1.Lines.Add(encrypted);

// Output:
// 9da2ae71a5378487114b430e5e230378

decrypted := CkCrypt2__decryptEncoded(crypt,encrypted);
Memo1.Lines.Add(decrypted);

// Output:
// 000102030405060708090a

CkCrypt2_Dispose(crypt);

end;