Cyberguille
Cyberguille

Reputation: 1602

how to encrypt password text input using script mode in Katalon ?

I have a csv with a list of users and passwords that I need check the login.

Is there any way to encrypt password text input using script mode in Katalon ?

I found an answer on katalon forums but they do that manually using a a tool of the IDE like you can see here Working with Sensitive Text

I would like to create an script that for every (user,password) encrypt the password and login using encrypted password.

@Keyword
    def  login(user, password, url){

        WebUI.navigateToUrl(url)

        WebUI.setText(findTestObject('Object Repository/Page_Sign in  My Page/input_SigninFormemail'),user)
        def password_encript = Encrypt(password)// Fictitious method that I would like to get

        WebUI.setEncryptedText(findTestObject('Object Repository/Page_Sign in  My Page/input_SigninFormpassword'), password_encript)

        WebUI.click(findTestObject('Object Repository/Page_Sign in  My Page/input_yt0'))

    }

Is there a method like Encrypt(password) in Katalon? Is there a way to do that in code?

Thanks in advance.

Upvotes: 2

Views: 2650

Answers (2)

sciguyCO
sciguyCO

Reputation: 23

I came across this question while investigating other Katalon encryption questions, and thought I may offer some late insight.

The "setEncryptedText(TestObject, encryptedText)" method is to allow you to store sensitive text in an encrypted form, which is then decrypted when entered into the web application.

Since your method is being passed 'password' as a string in cleartext, then why not just have the function do:

WebUI.setText(findTestObject('Object Repository/Page_Sign in  My Page/input_SigninFormpassword'), password)

Upvotes: 1

siranen
siranen

Reputation: 374

So to use Java Encryption : Blowfish with Text and Key. Here is my solution :

public static String encrypt(String strClearText,String strKey) throws Exception{
String strData="";

// streData - here you put your data

try {
    SecretKeySpec skeyspec=new SecretKeySpec(strKey.getBytes(),"Blowfish");
    Cipher cipher=Cipher.getInstance("Blowfish");
    cipher.init(Cipher.ENCRYPT_MODE, skeyspec);
    byte[] encrypted=cipher.doFinal(strClearText.getBytes());
    strData=new String(encrypted);

} catch (Exception e) {
    e.printStackTrace();
    throw new Exception(e);
}
return strData;

}

Upvotes: 0

Related Questions