メインコンテンツまでスキップ
バージョン:23.4

Text Encryption

Use these SenseTalk commands and functions if you need to send a password or other sensitive text in your script and don't want to pass the information as plain text. Encryption keys are generated by Eggplant Functional on a suite-by-suite basis. Note that you can also enter your own key using ASCII characters, or enter a key from another Eggplant Functional suite.

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 EncodeText. To properly decode the text, the function must receive the same key that was used to encode the text.

Parameters: Text to be decoded. Optional key to use for decryption. If the key parameter is omitted, the function uses the suite's encoding key.

Syntax:

DecodeText( encodedString {, keyToUse} )

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.
先端

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. Optional key to use for encryption. If the key parameter is omitted, the function uses the suite's encoding key.

Syntax:

EncodeText( plainTextString {, keyToUse} )

Example:

log encodeText("password1234")

Example:

put encodeText("eggplant", "B^6)n2+Q")
先端

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.

ノート

Eggplant Functional doesn't log or otherwise record the decoded text.

Parameters: An encoded text string. Optional key to use for encryption. If the key parameter is omitted, the function uses the suite's encoding key.

Syntax:

TypeEncodedText encodedString {, specificKey}

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: