encrypt()
Encrypt a supplied string according to the specified encryption type.
Syntax
Parameters
Parameter | Definition |
---|---|
str | string you want to encrypt |
type | 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 AES |
Description
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 ("").
Example
The following example shows how to encrypt a string:
# and prompt for the username and password
user_response = response("Username/Password",-1,"w=300,h=150",
[R_TEXT_FIELD_LABEL,"Username"],
[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
host="pund2k315";
port="3181";
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";
print(error);
}
}