Interview Q&A

How to encrypt and decrypt a Password in UFT?

Encryption

There are 2 simple ways to encrypt a password or any text in UFT (QTP).

  1. First simple way is using the Password Encoder Utility provided by HPE along with the installation of QTP.

To encode any string, open this utility from the below path:

C:Program Files (x86)HPUnified Functional TestingbinCryptonApp.exe

Password Encoder
Password Encoder

Now, enter the password/string to be encrypted in the Password field and Click on ‘Generate’ button.

The ‘Encoded string’ is generated in fraction of a second and we’re ready to go.

2. Another way is by using ‘Crypt’ utility Object

Code:

strPwd = “abc123”
varA = Crypt.Encrypt(strPwd)
MsgBox varA

Crypt
Crypt

 

 

 

 

 

 

Decryption

Now that we have learnt how to encrypt a password, we may also understand how to Decrypt an encrypted password.

Below is the code to do the same:

Browser(“micclass:=Browser”, “index:=0”).Page(“micclass:=Page”,”index:=0″).WebEdit(“micclass:=WebEdit”, “index:=0”).SetSecure sEPwd

‘Displaying the Decrypted Value
MsgBox Browser(“micclass:=Browser”, “index:=0”).Page(“micclass:=Page”,”index:=0″).WebEdit(“micclass:=WebEdit”, “index:=0”).GetROProperty(“text”)

Leave a Reply

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