GetSecret function

function GetSecret(secretName: string): string

Syncplify.me AFT! allows you to store secrets (strings) in its encrypted database, so you don’t have to put them in clear in your scripts. A typical example is a password to a remote file server, you definitely don’t want to type such password in plain-text in your script, so you can use GetSecret to retrieve it after concealing it in AFT!’s secrets database.

In Syncplify.me AFT! every secret is identified by another non-secret string, which is the secret’s “name” or “description”, which you decide when you create and store the secret. Let’s say, for example, that your SFTP server’s password is P@ssw0rd, you can store it encrypted in Syncplify.me AFT! and call it “my SFTP password”. If you do so, then you can write your script like this:

{
  var scli = new SftpClient();
  scli.Host = 'your.sftpserver.com:22';
  scli.User = 'someusername';
  scli.Password = GetSecret('my SFTP password');
  if (scli.Connect()) {
    // perform your file transfers...
    // ...
    // ...
    scli.Close();
  }
  scli = null
}

This is a very context-agnostic way to store and use any type of secret in Syncplify.me AFT!… for passwords specifically, don’t forget that most client objects provide the PassFromSecret property, which can be used like this:

{
  var scli = new SftpClient();
  scli.Host = 'your.sftpserver.com:22';
  scli.User = 'someusername';
  scli.PassFromSecret = 'my SFTP password';
  if (scli.Connect()) {
    // perform your file transfers...
    // ...
    // ...
    scli.Close();
  }
  scli = null
}