123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
simple password creator

--------------------------------------------------------------------------------

Description : this is the simple password creator used for mailing password to person who forgot his password

import java.util.*;
//import java.util.HashSet;
//import java.util.Random;

//created by pol ganesh(my personal page at http://ganeshpol007.bravehost.com)
public class PasswordCreator {

public static final String MIXED_CASE_PATTERN =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;

public PasswordCreator( ) {
}


/*********************************************************************************
*Description of getRandomNumbersSet method: it gives set of random numbers in the
* range of 0 to 51
*
*@Parameters
* setMaxSize:it decides size of set
*
*@Returns
* Set:Set of all random numbers
*/
public static Set getRandomNumbersSet(int setMaxSize) {
Random rand = new Random () ;
Set numberSet=new HashSet( );
while (numberSet.size() !=setMaxSize){

numberSet.add(new Integer(rand.nextInt(52)));
//System.out.println(" "+numberSet.size());

}
return numberSet;
}

/*********************************************************************************
*Description of getPassword method: this give Password in String Format whose
* Maximum length is less than 52 charecters
*
*@Parameter
* passwordLength - length of password require
*@Returns
* String: Password in String format
*/
public static String getPassword (int passwordLength) {
StringBuffer pw = new StringBuffer( ) ;
Set num=getRandomNumbersSet(passwordLength) ;
//System.out.println("set size is "+num.size( )) ;
Iterator it= num.iterator( ) ;
while(it.hasNext( )) {
Integer i=(Integer)it.next( ) ;
int i1=i.intValue( ) ;
// System.out.println(" "+i1) ;
pw.append(MIXED_CASE_PATTERN.charAt(i1)) ;
}
return ( pw.toString( ) ).trim( ) ;
//pw.append();
}


public static void main(String[] args) {
System.out.println(" "+getPassword(5));
}
}

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG