Sample code for 30+ languages & platforms
Delphi ActiveX

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat Delphi ActiveX Downloads

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

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
crypt: TChilkatCrypt2;
bdEncrypted: TChilkatBinData;
sbPlainText: TChilkatStringBuilder;

begin
success := 0;

crypt := TChilkatCrypt2.Create(Self);

bdEncrypted := TChilkatBinData.Create(Self);
sbPlainText := TChilkatStringBuilder.Create(Self);

sbPlainText.Append('Text to be encrypted');

// ...
// Set the secret key ...
// Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
// Set the IV if needed ...
// ...

crypt.Charset := 'utf-8';

success := crypt.EncryptSb(sbPlainText.ControlInterface,bdEncrypted.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(crypt.LastErrorText);
    Exit;
  end;
end;