Blog Archives

Simple method to generate random password

   public static String generateTempPassword(int length){
	   String character = "qwertyuioplkjhgfdsazxcvbnm1234567890POIUYTREWQASDFGHJKLMNBVCXZ!@#$%&";
	   StringBuffer sb = new StringBuffer();
	   while(length>0){
		   double index = Math.random() * character.length();
		   sb.append(character.charAt((int)index));
		   length--;
	   }
	   return sb.toString();
   }
Advertisements