How to Encyrpt and Decrypt Password in UFT?


We don’t want to share our application(say Oracle database) login password , but rather encrypt it and while using the SQL query we need it to be decrypted at runtime.


Firstly we will Encrypt the password and then decrypt it.


Approach 1:-

Using Crypt utlity Object. 
Method used :- Encrypt 

Crypt Syntax


Crypt Syntax
Code Example

Approach 2:-

Using Password Encoder (Tool in UFT)


1. Open Command Prompt and Type the path “C:Program Files (x86)HPUnified Functional TestingbinCryptonApp.exe” to Run it.

2.Start > All Programs > HP Software > HP Unified Functional Testing >Tools >Password Encoder

Note: Path can vary based on the UFT installation folder.

Click on Generate button to create the encrypted password.

Password Encoder UFT
Password Encoder


Now we have the encrypted password, we  need it to be decrypted before we can utilize in our SQL query connection string.

Hint:- For decrypting the password UFT, internally uses the “SetSecure” method, which automatically decrypt it .So we will leverage this approach to achieve the decryption.


'Password Encryption
Dim sPwd ,sEPwd,sDPwd
sPwd = "uftHelp"
sEPwd = Crypt.Encrypt(sPwd)
Msgbox sEPwd,,"Encryption"
'Password Decryption
sDPwd = fn_DecryptMe(sEPwd)
Msgbox sDPwd,,"Decryption"

'Function Name:- fn_DecryptMe
'Function Description:- Decrypt the given string
'Input Parameters:- Encrypted String
'Output Parameters:- Decrypted value
Public Function fn_DecryptMe(sEPwd)
'Closing the opened IE instance
Systemutil.CloseProcessByName "iexplore.exe"
'Launching the IE
'Mode = 7 (Displays the window as a minimized window. The active window remains active)
SystemUtil.Run "C:Program Files (x86)Internet Exploreriexplore.exe", "", "","",7
'Setting the value in Google url using SetSecure
If Browser("micclass:=Browser", "index:=0").WinEdit("micclass:=WinEdit", "index:=0").Exist Then
Browser("micclass:=Browser", "index:=0").WinEdit("micclass:=WinEdit", "index:=0").SetSecure sEPwd
'Taking the Decrypted Value
fn_DecryptMe = Browser("micclass:=Browser", "index:=0").WinEdit("micclass:=WinEdit", "index:=0").GetROProperty("text")
Print "Decryption failed, Please try again"
fn_DecryptMe = sEPwd
End If
'Closing the opened IE instance
Systemutil.CloseProcessByName "iexplore.exe"

End Function


2 thoughts on “How to Encyrpt and Decrypt Password in UFT?

  1. We don't need to install password encoder . it comes as in built tool .please read the above post carefully you will find the way to launch it.Thanks uftHelp team for such wonderful post .

Leave a Reply

Your email address will not be published. Required fields are marked *