Why Password Encryption is Needed?
How to Encrypt Passwords in QTP
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.
1 2 | password = "qwerty" msgbox Crypt.Encrypt(password) |
How to use encrypted passwords in your scripts
1 2 3 4 5 | password = "qwerty" sEncryptedPwd = Crypt.Encrypt(password) 'Enter Login Id & passwordBrowser( "" ).Page( "" ).WebEdit( "userid" ). Set "user1" Browser( "" ).Page( "" ).WebEdit( "password" ).SetSecure sEncryptedPwd |
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.