Encrypt Function

Action

Encrypts string or binary data into a printable format using RSA’s RC4 cipher. This function is useful for encrypting passwords and other sensitive data.

注: The Encrypt3DES function uses a higher security algorithm than this function and should be used in newly generated scripts to be FIPS compliant.

Include file

kernel.bdh

Syntax

Encrypt( in sData : string,
         in sKey  : string optional ): string;

Return value

  • encrypted string

Parameter Description
sData String or binary data to be encrypted
sKey String or binary data used as encryption key (optional).
注: The returned string is about 30% larger in size than the original data

Example

dcltrans
  transaction TMain
  var
    sUserPass  : string;
    sEncrypted : string;
  begin
    // Build your own authentication header
    AttributeGetString("Password", sUserPass);
    sEncrypted := Encrypt(sUserPass);
    Print(sEncrypted);
    sUserPass := Decrypt(sEncrypted);
    Print("decrypted password: " + sUserPass);
  end TMain;