Encrypt and Decrypt the password in UFT

In most of the scenarios, we require password to login into the application or database or in any tool.It is good practice not to expose the password in the script or data input. To achieve that, we can encrypt the password and use that encrypted password as input.

We will see how to encrypt and decrypt the password.

Password Encryption: Password can be encrypted in 2 ways in UFT.

1. Using the UFT in-built utility
2. Using Encrypt method

UFT in-built encryption tool: To access this go to the path – “C:\Program Files (x86)\HP\Unified Functional Testing\bin\CryptonApp.exe”

Write your password in ‘Password box’ and click on  Generate.You will get a encoded string i.e. encoded password.
That can be used to in place of actual password.



SetSecure method is used to set the encoded password as shown below. We are logging into the UFT sample application ‘Flight GUI’.

Dialog("Login").WinEdit("Agent Name:").Set "mercury" 
Dialog("Login").WinEdit("Password:").SetSecure "55a93575b17558ee6540ee42e898de43aca0e76a" 


Encrypt Method: There is an object called ‘Crypt’ which contains a method ‘Encrypt’. By using this, we can encode the password.

msgbox crypt.Encrypt("mercury")

Password Decryption: Decryption is possible in 2 ways.

1. Using GetRoProperty
2. Using the Input box

Using GetRoProperty: Using the GetRoProperty we can read the value of password field back. Take an example of gmail password editbox. We are typing the value in password field and reading it back.

Browser("Gmail").Page("Gmail").WebEdit("Passwd").SetSecure "55a93a42183972731bb82c0ccc45a9e82f339f87"
msgbox Browser("Gmail").Page("Gmail").WebEdit("Passwd").GetROProperty("value")

Using Inputbox: Open a notebook and write “InputBox “Show decrypted password in text box”, “Decrypt Password and save the file with the extension .vbs. We have given a name DecodePassword.

SystemUtil.Run "H:\DecodePassword.vbs"
Dialog("nativeclass:=#32770","text:=Decrypt Password").WinEdit("nativeclass:=Edit").SetSecure "55a93575b17558ee6540ee42e898de43aca0e76a"


Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...