Quality scale of a Password

Quality scale of a Password

Postby Silvio » Sat Apr 09, 2011 4:32 pm

How I can calc a quality of a Password ?

sample :

for 6 digit

Ql3Aj4 -> 35 bit

and show to a dialog a meter graph of the quality as this :



Image




I found also this http://www.ipi.org/help/help8_admin.nsf ... enDocument

I found this function how I can translate it on fwh ?
Code: Select all  Expand view
function passwordStrength(password)

{

        var desc = new Array();

        desc[0] = "Very Weak";

        desc[1] = "Weak";

        desc[2] = "Better";

        desc[3] = "Medium";

        desc[4] = "Strong";

        desc[5] = "Strongest";



        var score   = 0;



        //if password bigger than 6 give 1 point

        if (password.length > 6) score++;



        //if password has both lower and uppercase characters give 1 point      

        if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;



        //if password has at least one number give 1 point

        if (password.match(/\d+/)) score++;



        //if password has at least one special caracther give 1 point

        if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;



        //if password bigger than 12 give another 1 point

        if (password.length > 12) score++;



         document.getElementById("passwordDescription").innerHTML = desc[score];

         document.getElementById("passwordStrength").className = "strength" + score;

}
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Quality scale of a Password

Postby Silvio » Sat Apr 09, 2011 5:20 pm

I try with


function passwordStrength(cpass,nLenght)

Local desc := {"Very Weak","Weak","Better","Medium","Strong","Strongest"}
LOCAL aPwd := {}
Local score := 0
Local cUpperCase := "ABCDEFGHIJKLMNOPQRSTUVXYZ"
Local cLowerCase := "abcdefghijklmnopqrstuvxyz"
Local cDigit := "0123456789"

AAdd( aPwd, cUpperCase )
AAdd( aPwd, cLowerCase )
AAdd( aPwd, cDigit )


If len(alltrim(cpass)) > 6
score++
endif
n := 0
FOR i := 1 TO nLenght
n := IIf( n >2, 1, ++n )
if SubStr( aPwd[n], cpass, 1 )
score++
endif
next


but this make error

how I can make to see if on cpass there is one symbol of aPwd ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Quality scale of a Password

Postby nageswaragunupudi » Sat Apr 09, 2011 7:10 pm

Code: Select all  Expand view
function PassWordStrength( cPassword )

   local nScore    := 0

   //if password bigger than 6 give 1 point
   if Len( cPassWord ) > 6
      nScore++
   endif

   //if password has both lower and uppercase characters give 1 point
   if cPassWord HAS "[a-z]" .and. cPassWord HAS "[A-Z]"
      nScore++
   endif

   //if password has at least one number give 1 point
   if cPassWord HAS "\d+"
      nScore++
   endif

   //if password has at least one special caracther give 1 point
   if cPassWord HAS "[!,@,#,$,%,^,&,*,?,_,~,-,(,)]"
      nScore++
   endif

   if Len( cPassWord ) > 12
      nScore++
   endif

return nScore
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Quality scale of a Password

Postby Silvio » Sat Apr 09, 2011 9:10 pm

please can you explain me "HAS " command
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Quality scale of a Password

Postby nageswaragunupudi » Sat Apr 09, 2011 9:23 pm

<cString> HAS <cRegExp> returns .t. of <cRegExp> is found in <cString>

This command is available in xHarbour
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Quality scale of a Password

Postby Silvio » Tue Apr 12, 2011 7:19 am

NAGES OR DANIEL,
i USE METEREX FOR MAKE THE METER

@ 205, 12 METEREX oMeterQuality VAR nActual SIZE 180, 12 TOTAL 100 PIXEL;
GRADIENT CHUNK { { 1/2, nRGB( 255, 251, 229 ), nRGB( 250, 223, 143 ) } , ;
{ 1/2, nRGB( 244, 194, 51 ), nRGB( 252, 235, 173 ) } };
GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },;
{ 1/2, nRGB( 224, 238,237 ),nRGB( 219, 224, 233 ) } };
ROUND LINECOLORS nRGB( 110, 151,204 ), CLR_WHITE

hoW i CAN SIMULATE AS ON PICTURE ?

i HAVE THESE VALUES

Local desc := {"Very Weak","Weak","Better","Medium","Strong","Strongest"}

THE FIRST MUST BE RED
ORANGE
YELLOW
THE LAST MUST BE GREEN
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Quality scale of a Password

Postby Silvio » Tue Apr 12, 2011 4:24 pm

ANY SOLUTION FOR THE METER ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 102 guests