Sample code for 30+ languages & platforms
Delphi ActiveX

Obfuscate String

Demonstrates how to obfuscate and unobfuscate a string.

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;
sb: TChilkatStringBuilder;
s: WideString;
sb2: TChilkatStringBuilder;
s2: WideString;

begin
success := 0;

sb := TChilkatStringBuilder.Create(Self);

s := 'Hello World!';

sb.Append(s);
Memo1.Lines.Add(sb.GetAsString());

// Output is "Hello World!";

// Obfuscate the string.
// This is NOT encryption.  It's just a simple obfuscation.
sb.Obfuscate();
Memo1.Lines.Add(sb.GetAsString());

// Output is 2GsgGhbSQVyG8Vb9

// -------------------------
// Unobfuscate.
sb2 := TChilkatStringBuilder.Create(Self);
s2 := '2GsgGhbSQVyG8Vb9';
sb2.Append(s2);
sb2.Unobfuscate();

Memo1.Lines.Add(sb2.GetAsString());

// Output is "Hello World!";
end;