Random Password Generator in Java Example Source Code

Generating Random Password in Java


In many cases like while we perform forgot password we need to generate random password. This Example Source code will help you to generate it. In this example we used Random class in util package to generate random number, by using that number we generate the password. Just copy and paste the below example source code.

import java.util.Random;
class RandomPassword{
public static void main(String arg[]){
String str=new String("G12HIJdefgPQRSTUVWXYZabc56hijklmnopqAB78CDEF0KLMNO3rstu4vwxyz9");
StringBuffer sb=new StringBuffer();
String ar=null;
Random r = new Random();
int te=0;
for(int i=1;i<=6;i++){
te=r.nextInt(62);
ar=ar+str.charAt(te);
sb.append(str.charAt(te));
}
String abc="im&vinoth&this&is&my&first+prg";
char arr[]=str.toCharArray();
System.out.println(ar);
System.out.println(sb.toString());
for(int i=0;i<arr.length;i++)
System.out.print("Generated Random Password String=" +arr[i]);
}
}



Related Topic PHP Code Generate Random String for Password
Create Random String,Password
Java - Create Random Number
Java MD5 Encryption - String
Strong Random Password Generator in php

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback