Results 1 to 2 of 2
Thread: Password Strength Checker
- 03-04-2014, 03:58 PM #1
Member
- Join Date
- Mar 2014
- Posts
- 1
- Rep Power
- 0
Password Strength Checker
it had no syntax error but plsease tell me if there would be any other error or if i would receive a wrong result
import java.util.*;
class tester
{
public static void test()
{
Scanner input=new Scanner(System.in);
int size= 0;
System.out.println("Enter your password:");
String enter=input.next();
size = enter.length();
//puttinng input into an array
char[] b = new char[size];
enter.getChars(0,size,b,0);
int c, u=0, l=0, d=0, m=0, t=0, cu=0, cl=0, s=0, sd=0 , only=0;
c = size * 4;
for(char o:b){
//checking UpperCases
if(Character.isUpperCase(o)){
u = u + 2;
}
//checking LowerCases
if(Character.isLowerCase(o)){
l = l + 2;
}
//checking Digits
if(Character.isDigit(o)){
d= d + 2;
}
//checking number of digits between first and last char
for(int i=1;i<size;i++){
if(Character.isDigit(b[i])){
m = m+2;
}
}
//checking number of Character used more than one time
for(int k=1;k<size;k++){
if((int)o == (int)b[k]){
t = t + 2;
}
}
//testing if any of the character are in alphabetic order(uppercase)
int p =(int) o;
if(p >=65 && p<=90){
for(int k=1;k<size;k++){
int r = (int) b[k];
if(r == p-1){
s = s + 2;
}
}
}
//testing if any of the character are in alphabetic order(lowercase)
if(p >=97 && p<=122){
for(int k=1;k<size;k++){
int r = (int) b[k];
if(r == p-1){
s = s + 2;
}
}
}
//testing if any of the character are in order (digits)
if(p >=48 && p<=57){
for(int k=1;k<size;k++){
int r = (int) b[k];
if(r == p-1){
sd = sd + 2;
}
}
}
for(int k=1;k<size;k++){
//testing number of consecutive uppercase letters
if(Character.isUpperCase(o)){
if(Character.isUpperCase(b[k])){
cu = cu + 2;
}
}
//testing number of consecutive lowercase letters
if(Character.isLowerCase(o)){
if(Character.isLowerCase(b[k])){
cl = cl + 2;
}
}
}
//testing if there are only letters
int a =0;
if(Character.isLetter(o)){
a = a+1;
if(a == size){
only = size;
}
}
//testing if there are only digits
int dig =0;
if(Character.isDigit(o)){
dig = dig+1;
if(dig == size){
only = size;
}
}
}
int points = c+u+l+d+m;
int penalities =t+cu+cl+s+sd+only;
int score = points - penalities;
//Final Step: Testing the score
if(score<=29){
System.out.println("weak");
}
if(score<=59 && score>=30){
System.out.println("moderate");
}
if(score<=79 && score>=60){
System.out.println("strong");
}
if(score>=80){
System.out.println("very strong");
}
}
}
- 03-04-2014, 04:30 PM #2
Re: Password Strength Checker
When posting code, please use the code tags to preserve formatting.
What does this code do? Have you run through it with a bunch of example input?How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
Similar Threads
-
Password Checker
By lily_ruiz_06 in forum New To JavaReplies: 4Last Post: 02-17-2013, 11:47 PM -
how to check password for 3 times enterd wrong password
By sk.mahaboobbhasha@gmail.c in forum New To JavaReplies: 2Last Post: 11-14-2008, 08:53 PM -
How to check password of a jsp/html with the password of Database(mysql) #1
By sk.mahaboobbhasha@gmail.c in forum Java ServletReplies: 2Last Post: 11-14-2008, 02:11 PM -
WiFi signal strength
By islamfunny in forum CLDC and MIDPReplies: 1Last Post: 10-02-2008, 09:53 AM
Bookmarks