Text Encryption
On this page:
Tech Talk
The encryption method used by these commands and functions is based on a Vigenère cypher. The strength of the encryption is in large part based on the strength of the key. Longer keys with random characters are preferred.
Keys generated by Eggplant Functional are 16 random characters in length. You can find the key on the suite's Settings tab in the Suite Text Encoding Key section.
If you use scripts across different suites, you can change the key on the Settings tab so that different suites use the same key. Note that the suite's key is used only if you don't specify a key in the command or function.
DecodeText Function
Behavior: Decodes text that was encoded using EndcodeText. To properly decode the text, the function must receive the same key that was used to encode the text.
Parameters: Text to be decoded (in quotation marks). Optional key to use for decryption (in quotation marks). If the key parameter is omitted, the function uses the suite's encoding key.
Syntax:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
Example:
log DecodeText("FA4gp+6RO-N>")
Example:
connect {host:"192.168.120.128", port:5900, password:decodeText("ITOTnmIRa","B^6)n2+Q")} //Allows you to display the encrypted value for the SUT's password instead of the actual password
Example:
set myDB to {type:"odbc", DSN:"mySQLDB", user:"root", password:decodetext("%s_z*A?>Z")} //Allows you to display the encrypted value for a database connection instead of the actual password.
Tip: Use the DecodeText function in the Ad Hoc Do Box to easily see the decrypted string without having to alter your scripts.
Related:
EncodeText Function
Behavior: Encodes text using an encryption key.
Parameters: Text to be encoded (in quotation marks). Optional key to use for encryption (in quotation marks). If the key parameter is omitted, the function uses the suite's encoding key.
Syntax:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
Example:
log encodeText("password1234")
Example:
Tip: Use the EncodeText function in the Ad Hoc Do Box to easily get the encrypted string without having to alter your scripts.
Related:
TypeEncodedText Command
Behavior: Internally decodes encoded text, like DecodeText does, and sends the resulting keystrokes to the SUT. This command lets you send information, such as passwords, that isn't readable in a script file.
Note: Eggplant Functional doesn't log or otherwise record the decoded text.
Parameters: An encoded text string. Optional key to use for encryption (in quotation marks). If the key parameter is omitted, the function uses the suite's encoding key.
Syntax:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
Example:
TypeEncodedText "FA4gp+6RO-N>" //Sends the encoded text to the SUT
Example:
params decryptkey //Parameterizes the script to receive the decryption key via a command line call to run the script. Example decryption key: "pegasus"
assert that decryptkey is not empty with message "Check that a decryption key has been provided." //Checks that a decryption key has been provided via the command line call and throws an exception if not
Log "Typing the password now."
TypeEncodedText "VMOR`Wbe",decryptkey
Example:
Use code such as this to read an encryption key and credentials from an external file (Excel). Assumes all stored passwords have been encrypted using the same encryption key.
set infoSource to Workbook(ResourcePath("KeySaver.xlsx"))
put worksheet(infoSource, 1) into Sheet1
put worksheet(infoSource, 2) into Sheet2
put cell(Sheet1, "A1") into encryptKey // Puts the encryption key into a variable
Put random(20) into UserNum // Generates a random number, used to select one of the 20 users from the file
typetext(cell(Sheet2,"A"&UserNum)), tabKey // Types username, then tabs to next field
Put cell(Sheet2,"B"&UserNum) into MyPass // Puts the corresponding user's encrypted password into a variable
TypeEncodedText MyPass, encryptKey // Sends the unencrypted keystrokes for the password to the SUT
Click "OK_Button"
Related: