Saturday, 9 July 2016

password encode and decode program

public class passworddecode {
WebDriver driver;
 @Test
 public void f() throws Exception {
 driver = new FirefoxDriver();

driver.get("http://gmail.com");

/*driver.findElement(By.name("Email")).sendKeys("xxx.chary");
 driver.findElement(By.name("signIn")).click();
 Thread.sleep(20000);
 driver.findElement(By.id("Passwd")).sendKeys("saritha123");
 driver.findElement(By.id("signIn")).click();*/

String encodedPasswd="c2FyaXRoYTEyMw==";
driver.findElement(By.id("Email")).sendKeys("xxx.chary");
driver.findElement(By.id("next")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='Passwd']")).sendKeys(decodeStr(encodedPasswd));

}
@Test
public static String decodeStr(String encodedStr){
byte[] decoded = Base64.decodeBase64(encodedStr);
return new String(decoded);
}
}

No comments:

Post a Comment