This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.1 for BMC Helix Operations Management. Open link


Encrypt a supplied string according to the specified encryption type.


encrypt(str,type,[optional type])





String you want to encrypt


Encryption type of str

Valid Values 

AES - Returns a AES encryption of the supplied str.

 DES-Returns a DES encryption of the supplied str.

PEM-Returns an encryption of str for use in PATROL Event Manager functions

Default Value

If type is specified as something other than AES, DES or PEM, AES is used.

optional type

Type of encryption

Valid Values 

STATIC - Encrypts with a static key.

DYNAMIC - Encrypts with a dynamic key.

Default Value


If the optional type is not specified, the default value will be STATIC.


The encrypt() function encrypts the supplied string str according to the encryption type parameter. The type parameter can have one of these values, AES, DES or PEM.

If type is AES, the function returns a AES encryption of the supplied string str

If type is DES, the function returns a DES encryption of the supplied string str

If type is PEM, the function returns an encryption of the AES encryption of str. Use the PEM encryption type when using the string in PATROL Event Manager functions, such as remote_open()

If you are running the stand-alone compiler/interpreter, the encrypt() function always returns the empty string ("").


The following example shows how to encrypt a string:

# Open a connection to a remote Agent
# and prompt for the username and password
user_response = response("Username/Password",-1,"w=300,h=150",
[R_TEXT_FIELD_LABEL,"Password"," ","e=0"]);
# Check that the OK button was pressed
status = trim(nthline(user_response, 1),"\n");
if (status) {
# Extract the username and password
username = trim(nthline(user_response, 2),"\n");
password = trim(nthline(user_response, 3),"\n");
# Encrypt the password
encrypted_passwd = encrypt(password, "PEM");
# Open the remote connection
sess = remote_open(host,port,"PEM",username,encrypted_passwd);
if (sess=="") {
error = "Error opening session to the Patrol Agent on the
target Machine\n".
"Please make sure the values are correct for:\n".
" Target Host: " . host."\n".
" Target Port: " . port."\n".
" Username: ".trim(nthline(user_response, 2),"\n") ."\n".
" Password: ". trim(nthline(user_response, 3),"\n")."\n";

Was this page helpful? Yes No Submitting... Thank you