FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Quality scale of a Password
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Quality scale of a Password
Posted: Sat Apr 09, 2011 04: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 :








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 (fw): Select all Collapse
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
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Quality scale of a Password
Posted: Sat Apr 09, 2011 05: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Quality scale of a Password
Posted: Sat Apr 09, 2011 07:10 PM
Code (fw): Select all Collapse
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
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Quality scale of a Password
Posted: Sat Apr 09, 2011 09:10 PM

please can you explain me "HAS " command

Best Regards, Saludos



Falconi Silvio
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Quality scale of a Password
Posted: Sat Apr 09, 2011 09: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
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Quality scale of a Password
Posted: Tue Apr 12, 2011 07: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
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Quality scale of a Password
Posted: Tue Apr 12, 2011 04:24 PM

ANY SOLUTION FOR THE METER ?

Best Regards, Saludos



Falconi Silvio

Continue the discussion