Delphi DLL
Delphi DLL
Resolve the FTP Password from OS Secure Storage
See more FTP Examples
Demonstrates the EnableSecrets property, which lets password properties contain a secret specification beginning with !! that Chilkat resolves from the operating system's secure storage instead of using the literal text.
Background: This is a cleaner alternative to reading a secret yourself and assigning it: with
EnableSecrets on, you set the password to a reference like !!my_secret_name and Chilkat fetches the real value from the platform's secure store. The literal password never appears in your source or configuration, which is exactly the practice recommended throughout these examples.Chilkat Delphi DLL Downloads
var
success: Boolean;
ftp: HCkFtp2;
begin
success := False;
ftp := CkFtp2_Create();
CkFtp2_putHostname(ftp,'ftp.example.com');
CkFtp2_putUsername(ftp,'myFtpLogin');
// EnableSecrets (default 0) allows password properties to contain a "secret specification"
// beginning with "!!" that Chilkat resolves from the operating system's secure storage instead
// of using the literal text.
CkFtp2_putEnableSecrets(ftp,True);
// Provide a secret specification rather than a literal password. Chilkat looks up the named
// secret in the OS secure store.
CkFtp2_putPassword(ftp,'!!my_ftp_password_secret');
success := CkFtp2_Connect(ftp);
if (success = False) then
begin
Memo1.Lines.Add(CkFtp2__lastErrorText(ftp));
Exit;
end;
Memo1.Lines.Add('Connected using a password from OS secure storage.');
success := CkFtp2_Disconnect(ftp);
if (success = False) then
begin
Memo1.Lines.Add(CkFtp2__lastErrorText(ftp));
Exit;
end;
CkFtp2_Dispose(ftp);