Encode Password using Base64 Java - Selenium Webdriver

One of the most common practice while automating websites which have passwords and other personal information  is encoding.

Base64 is a method of encoding every 3 bytes of input into 4 bytes of output; it is commonly used to encode photos or audio to send in emails, and a way to hide webpage authentication from casual snooping. Here is an example of how to code a Base64 encoder in Java for Selenium WebDriver:


WebDriver wd = new FirefoxDriver();
WebElement pwd = wd.findElement(By.id("passwd"));

byte[] encodedBytes = Base64.encodeBase64("TextforEncoding".getBytes());
System.out.println("encodedBytes " + new String(encodedBytes));
byte[] decodedBytes = Base64.decodeBase64(encodedBytes);
System.out.println("decodedBytes " + new String(decodedBytes));

Happy Encoding!


Post a Comment

Popular posts from this blog

XPATH for IE / internet explorer

RPA - Blue Prism, OpenSpan, Automation Anywhere vs UIPath