QTP VBScript new series + Interview Question Bank on QTP for enrichment of Knowledge in QTP

This Site has been brought to you by HP Certified Expert of QTP.

Exciting new articles for October:

1) QTP Tip:Deselect all Radio Buttons

2) HP QTP Crypt Object

3)Adding Hyperlinks in Excel Spreadsheet

Best of Luck Friends ! ! !

Expert QTP

All Articles are Copyright Protected. These are Free for Reading & Personal Use. Reproduction in Any Form without the Permission is Illegal & Strictly Prohibited.

Copyright © 2009 ExpertQTP

Google Search

Saturday, October 3, 2009

HP QTP Crypt Object

As the name implies, the "Crypt" object in HP Quicktest Professional is for encrypting the strings which can only be understood by QTP's "SetSecure" method. "Encrypt" is the only method supported by the QTP "Crypt" object.

The syntax is:

Crypt.Encrypt(Your String)

An example for the same would be:

'The string "ExpertQTP" would be encrypted

var=Crypt.Encrypt("ExpertQTP") msgbox var

The output of the above code would be "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61". As you can see, this string is encrypted which cant be understood by anyone.

Please Note: Recording on password protected fields automatically encrypts your string for example

WebEdit("name:=Password").SetSecure "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61"

Now lets see how to decrypt our string. Sounds Interesting.. Alright!! Lets read more.

Open your Internet Explorer browser and navigate to Google homepage. Copy and paste the below mentioned script in your QTP editor and run it.

SetSecure "4ac6e9ba26cad2886bf331a767bfa1ce055f68e66bed5d61"

The output of the above code would be:

As you can see, you can even use SetSecure method on non password fields as well.

Another example of Crypt usage would be to create a function inside a Library and call inside your QTP Script.

Print Crypt_Func(pwd)

'The below function is there in the Library

Function Crypt_Func(password)
End Function

I am going to present you another example how we can encrypt a string: Using "Mercury.Encrypter"

Set var=CreateObject("Mercury.Encrypter")
Msgbox var.Encrypt("QTP")
Set var=Nothing 'Release the Object reference

Do you think of any other method or Utility to encrypt Strings? If your answer is No, then let me tell you there is a small utility program provided by QTP for encrypting strings. Its "Password Encoder".

How do I access this "Password Encoder" now? Thats simple!!
Navigate to Start-> All Programs-> QuickTest Professional-> Tools-> Password Encoder

Provide your string inside the "Password" field and click on the Generate button. Your encrypted string would be displayed inside the "Encoded String" field.

If you like this Article, I would suggest you to subscribe my RSS feed. This way you will get all new future articles directly into your mailbox.

No comments:

Copyright © 2009 ExpertQTP