Requirement:-
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.
Solution:-
Firstly we will Encrypt the password and then decrypt it.
Encryption:-
Approach 1:-
Using Crypt utlity Object.
Method used :- Encrypt
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.
Solution:-
Firstly we will Encrypt the password and then decrypt it.
Encryption:-
Approach 1:-
Using Crypt utlity Object.
Method used :- Encrypt
![]() |
Syntax |
Code:-
![]() |
Code Example |
Approach 2:-
Using Password Encoder (Tool in UFT)
Open:-
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.
Note: Path can vary based on the UFT installation folder.
Click on Generate button to create the encrypted password.
![]() |
Password Encoder |
Decryption:-
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.
Code:-
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.
Code:-
'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************************************************
'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", "www.google.com", "","",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")
Else
Print "Decryption failed, Please try again"
fn_DecryptMe = sEPwd
End If
'Closing the opened IE instance
Systemutil.CloseProcessByName "iexplore.exe"
End Function
2 replies on “How to Encyrpt and Decrypt Password in UFT?”
Hi! How install only the password encoger?
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 .