public class PasswordGenerator {
static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
static Random rnd = new Random();
public String randomString(int len)
{
StringBuilder sb = new StringBuilder(len);
for( int i = 0; i < len; i++ )
sb.append( AB.charAt( rnd.nextInt(AB.length()) ) );
System.out.println(sb);
return sb.toString();
}
public static void main(String a[]){
PasswordGenerator obj=new PasswordGenerator();
String s=obj.randomString(6);
System.out.println(s);
}
static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
static Random rnd = new Random();
public String randomString(int len)
{
StringBuilder sb = new StringBuilder(len);
for( int i = 0; i < len; i++ )
sb.append( AB.charAt( rnd.nextInt(AB.length()) ) );
System.out.println(sb);
return sb.toString();
}
public static void main(String a[]){
PasswordGenerator obj=new PasswordGenerator();
String s=obj.randomString(6);
System.out.println(s);
}
0 comments:
Post a Comment