/* Following is a Java program to check strength of password entered by user utilizing following parameters a)Combination of alphabets with digits & special symbols b)Length of password c)Repetition of characters in password
This program uses HashTable to store frequency of characters. */
public static void main(String[] args) throws IOException {
System.out.println("Enter password: "); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String password=br.readLine(); int strength=passwordStrength.checkStrength(password); // checkStrength static method called System.out.println("Strength is "+strength+" out of 100");
if (strength<0) System.out.println("Very Weak Password"); else if (strength<34) System.out.println("Weak Password"); else if(strength<68) System.out.println("Good Password"); else System.out.println("Strong Password");
}
static public int checkStrength(String password) { int strength; //Initially parameter evaluation int len =password.length(),no_of_digits=0,no_of_alpha=0,no_of_spl=0; Hashtable freq = new Hashtable ();
char c;
Integer t;
for(int i=0;i
{ //Evaluating number of types of characters
c=password.charAt(i);
if (Character.isDigit(c))
no_of_digits++;
else if (Character.isLetter(c))
no_of_alpha++;
else
no_of_spl++;
if (!freq.containsKey(c))
freq.put(c, 1);
else
{
t=freq.get(c);
freq.remove(c);
freq.put(c,t+1);
} //End of for loop
}
//Finally Evaluation of strength
strength=len*4;
Enumeration e=freq.keys();
while(e.hasMoreElements())
{
c=(Character)e.nextElement();
if( freq.get(c)>1)
{
strength-=5*(Integer)freq.get(c);//Reduction on behalf of repetition
} //End of loop
}
I am working on new theme for blog and have changed the previous look with this new CSS template, students interested in improving blog theme kindly send suggestions and search for link to better theme(s) so that Blog can be renovated