Saturday, 22 January 2011


This article covers the different aspects of password encryption in QTP. It talks about why password encryption may be needed, how to encrypt passwords using QTP and how to use the encrypted passwords in our scripts. Lets discuss all these points one by one.
Why Password Encryption is Needed?
In most of the automation projects, the scripts would be dealing with various user ids and passwords, be it application credentials, DB passwords and other similar things. And in many cases, the automation scripts would be maintained by multiple people/teams. In such situations, encrypted passwords can be used so that the original passwords are not exposed unnecessarily.
How to Encrypt Passwords in QTP:
QTP provides the following two methods to encrypt passwords -
a) Using Password Encoder Utility: Password Encoder is a tool/utility provided by QTP to encode passwords. To encode any password using this tool -
i) Go to All Programs > HP QuickTest Professional > Tools > Password Encoder
ii) Enter the password to be encrypted in the Password field and click on Generate button. The encrypted password will be displayed in the ‘Encoded string’ field (as shown in the below figure).
Encrypted Password for ‘qwerty’
b) Using Crypt Object, Encrypt Method: Crypt is a QTP utility object which provides a method called Encrypt to encode strings. The below code shows how a password can be encoded using Encrypt method.
password = “qwerty”
msgbox Crypt.Encrypt(password)                                   
How to use encrypted passwords in our scripts:
QTP provides SetSecure method to set encrypted values in text fields. Unlike the normal Set method, which sets the plain text in a text field, SetSecure method decrypts the encrypted password first, and then sets the original decrypted value in a password field.
Example:
password = “qwerty”
sEncryptedPwd = Crypt.Encrypt(password)
‘Enter Login Id & password
Browser(“”).Page(“”).WebEdit(“userid”).Set “user1″
Browser(“”).Page(“”).WebEdit(“password”).SetSecure sEncryptedPwd
In the above example, sEncryptedPwd variable contains the encrypted password. SetSecure method first decodes this password internally and then sets the decoded/decrypted password in the password field.
 
Note: SetSecure method decrypts a password only when it is in encrypted state. If we try to pass a plain (non encrypted) password to SetSecure method, then rather than decrypting the password, it just sets the same value in the text field.

0 comments:

Post a Comment

TrainingHUB. Powered by Blogger.

Total Pageviews

THE BEST QTP TRAINING INSTITUTE IN HYDERABAD

QTP Training in hyderabad

Sql Tutorial

Popular Posts

Our Facebook Page

TrainingHUB

Followers