Sample code for 30+ languages & platforms
Delphi ActiveX

Base64 Encode/Decode a String

See more Encryption Examples

_LANGUAGE_ example to base-64 encode and decode 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;
bd: TChilkatBinData;
s: WideString;
strBase64: WideString;
bd2: TChilkatBinData;
decoded: WideString;

begin
success := 0;

bd := TChilkatBinData.Create(Self);

s := 'A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump';

success := bd.AppendString(s,'utf-8');

strBase64 := bd.GetEncoded('base64');
Memo1.Lines.Add(strBase64);

// To decode:
bd2 := TChilkatBinData.Create(Self);
bd2.AppendEncoded(strBase64,'base64');

decoded := bd2.GetString('utf-8');
Memo1.Lines.Add(decoded);
end;