By using this Password encoder, we can secure the password.Its so simple to Encrypt.
import java.util.Base64;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class PasswordEncryptor {
WebDriver driver;
static String decodepassword=”aGFwcHltYW4xNjM=”;
public static String getDecodedpassword()
{
return new String(Base64.getDecoder().decode(decodepassword.getBytes()));
}
@Test
public void test1()
{
System.out.println(getDecodedpassword());
driver=new FirefoxDriver();
driver.get(“https://accounts.google.com”);
driver.findElement(By.id(“Email”)).sendKeys(“[email protected]”);
driver.findElement(By.id(“Passwd”)).sendKeys(getDecodedpassword());
driver.findElement(By.id(“signIn”)).click();
}
}
This is cool !!
LikeLike
What is the java version supported for base64, if i try importing import java.util.Base64; import cannot be resolved error is coming, so tried using instead import org.apache.commons.codec.binary.Base64;, but no luck, i am using JRE7 in buildpath… Any help will be appreciated…
LikeLike
I am using JAVA- version 8
LikeLiked by 1 person
tried this stackoverflow answer… http://stackoverflow.com/questions/10945147/how-to-to-use-base64-java-file-in-my-code
LikeLike