Working with Sensitive Text

This is a companion discussion topic for the original entry at

i just want to know the same process can be done in script only , the process of converting a raw text into encrypted text .
can any one provide an example,

1 Like

I am saying that if there is a script equivalent of this step

1 Like

Thank you for all of this.

I am wondering, is it possible to encrypt a password set as a variable in a profile?

Encrypt the string you want to use as a password under Help -> Encrypt Text and then store the encrypted text in a variable in your execution profile. You can then call that variable with WebUI.setEncryptedText.



if you will need something more

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

public class EncryptionDemo {

    Cipher ecipher;
    Cipher dcipher;

    EncryptionDemo(SecretKey key) throws Exception {
        ecipher = Cipher.getInstance("AES");
        dcipher = Cipher.getInstance("AES");
        ecipher.init(Cipher.ENCRYPT_MODE, key);
        dcipher.init(Cipher.DECRYPT_MODE, key);

    public String encrypt(String str) throws Exception {
        // Encode the string into bytes using utf-8
        byte[] utf8 = str.getBytes("UTF8");

        // Encrypt
        byte[] enc = ecipher.doFinal(utf8);

        // Encode bytes to base64 to get a string
        return new sun.misc.BASE64Encoder().encode(enc);

    public String decrypt(String str) throws Exception {
        // Decode base64 to get bytes
        byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);

        byte[] utf8 = dcipher.doFinal(dec);

        // Decode using utf-8
        return new String(utf8, "UTF8");

    public static void main(String args []) throws Exception

        String data = "My secret key!";
        String k = "Bar12345Bar12345";

        //SecretKey key = KeyGenerator.getInstance("AES").generateKey();
        SecretKey key = new SecretKeySpec(k.getBytes(), "AES");
        EncryptionDemo encrypter = new EncryptionDemo(key);

        System.out.println("Original String: " + data);
        String encrypted = encrypter.encrypt(data);
        System.out.println("Encrypted String: " + encrypted);
        String decrypted = encrypter.decrypt(encrypted);
        System.out.println("Decrypted String: " + decrypted);

Original String: My secret key!
Encrypted String: V7ZT0F94d8E78e1+iRWGMg==
Decrypted String: My secret key!

Is it possible somehow to add encrypted Text without using the ToObject??? If you do not have that option can you please add it? This is really important feature.
Like in the below cases

'Input username and password on authentication dialog.'
WebUI.authenticate('', 'admin', GlobalVariable.encrypted_pw, 12)

WebUI.openBrowser(‘http:// USERNAME:Encrypted_PASSWORD’)