How to Encrypt password for Selenium Webdriver

To secure our passwords we can use Base64 encoding scheme in Selenium WebDriver. We will import this Bas64 class in our script to get the decode password.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
import java.util.Base64;

public class passwordEncryption(){

public static WebDriver driver;

String password = “simpletesters123”;

String encryptedPassword = Base64.getDecoder().decode(decodepassword.getBytes());

driver = new FirefoxDriver();
driver.get(“http://facebook.com”);
driver.findElement(By.id(“email”)).sendKeys(“Hello”);
driver.findElement(By.id(“pass”)).sendKeys(“encryptedPassword “);
driver.findElement(By.id(“u_o_q”)).click();
driver.close();

}

Advertisements