Micro Focus Expert
Micro Focus Expert

<(UFT) Support tip> How to use Encrypt/Decrypt methods available on API testing from a GUI Test

I recently got this question and I’d like to share the answer with the community.
API Testing offers an encryption mechanism that enables the user to encrypt or decrypt strings (like passwords) through the EncryptionMngr object.

You can get more information on how to use these methods on API tests from UFT’s online help center:

The option of using these methods from GUI tests is useful in scenarios where we want to share encrypted data between API and GUI tests.

The below sample snippet shows how to accomplish this:

'Get the path of the ST utilities dll file from your UFT machine
lib = Environment("ProductDir") + "\bin\HP.Utt.St.Utilities.dll"
'ST Utilities dll is .net assembly, so we can create an instance of it using DOTNetFactory
Set STUtilities = DOTNetFactory.CreateInstance("HP.Utt.St.Utilities.Encryption.EncryptionManager", lib).Instance
'Here an example on how to encrypt a string. The ecrypted value will look like this: w2DbF/PiKci8CKBGp2Buww==
myEncryptedValue = STUtilities.Encrypt("Alvaro")
'Here an example on how to decrypt it 
msgbox STUtilities.Decrypt(myEncryptedValue, true)


HPE Support
If you find this useful, mark Kudos.

Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.