ÿþ/ /   P a s s w o r d   s t r e n g t h   m e t e r  
 / /   T h i s   j Q u e r y   p l u g i n   i s   w r i t t e n   b y   f i r a s   k a s s e m   [ 2 0 0 7 . 0 4 . 0 5 ]  
 / /   F i r a s   K a s s e m     p h i r a s . w o r d p r e s s . c o m   | |   p h i r a s   a t   g m a i l   { d o t }   c o m  
 / /   f o r   m o r e   i n f o r m a t i o n   :   h t t p : / / p h i r a s . w o r d p r e s s . c o m / 2 0 0 7 / 0 4 / 0 8 / p a s s w o r d - s t r e n g t h - m e t e r - a - j q u e r y - p l u g i n /  
  
 v a r   s h o r t P a s s   =   ' T ú l   r ö v i d '  
 v a r   b a d P a s s   =   ' G y e n g e '  
 v a r   g o o d P a s s   =   ' J ó '  
 v a r   s t r o n g P a s s   =   ' E r Qs '  
  
  
  
 f u n c t i o n   p a s s w o r d S t r e n g t h ( p a s s w o r d , u s e r n a m e )   {  
         s c o r e   =   0    
          
         / / p a s s w o r d   <   4  
         i f   ( p a s s w o r d . l e n g t h   <   4   )   {   r e t u r n   s h o r t P a s s   }  
          
         / / p a s s w o r d   = =   u s e r n a m e  
         i f   ( p a s s w o r d . t o L o w e r C a s e ( ) = = u s e r n a m e . t o L o w e r C a s e ( ) )   r e t u r n   b a d P a s s  
          
         / / p a s s w o r d   l e n g t h  
         s c o r e   + =   p a s s w o r d . l e n g t h   *   4  
         s c o r e   + =   (   c h e c k R e p e t i t i o n ( 1 , p a s s w o r d ) . l e n g t h   -   p a s s w o r d . l e n g t h   )   *   1  
         s c o r e   + =   (   c h e c k R e p e t i t i o n ( 2 , p a s s w o r d ) . l e n g t h   -   p a s s w o r d . l e n g t h   )   *   1  
         s c o r e   + =   (   c h e c k R e p e t i t i o n ( 3 , p a s s w o r d ) . l e n g t h   -   p a s s w o r d . l e n g t h   )   *   1  
         s c o r e   + =   (   c h e c k R e p e t i t i o n ( 4 , p a s s w o r d ) . l e n g t h   -   p a s s w o r d . l e n g t h   )   *   1  
  
         / / p a s s w o r d   h a s   3   n u m b e r s  
         i f   ( p a s s w o r d . m a t c h ( / ( . * [ 0 - 9 ] . * [ 0 - 9 ] . * [ 0 - 9 ] ) / ) )     s c o r e   + =   5    
          
         / / p a s s w o r d   h a s   2   s y b o l s  
         i f   ( p a s s w o r d . m a t c h ( / ( . * [ ! , @ , # , $ , % , ^ , & , * , ? , _ , ~ ] . * [ ! , @ , # , $ , % , ^ , & , * , ? , _ , ~ ] ) / ) )   s c o r e   + =   5    
          
         / / p a s s w o r d   h a s   U p p e r   a n d   L o w e r   c h a r s  
         i f   ( p a s s w o r d . m a t c h ( / ( [ a - z ] . * [ A - Z ] ) | ( [ A - Z ] . * [ a - z ] ) / ) )     s c o r e   + =   1 0    
          
         / / p a s s w o r d   h a s   n u m b e r   a n d   c h a r s  
         i f   ( p a s s w o r d . m a t c h ( / ( [ a - z A - Z ] ) / )   & &   p a s s w o r d . m a t c h ( / ( [ 0 - 9 ] ) / ) )     s c o r e   + =   1 5    
         / /  
         / / p a s s w o r d   h a s   n u m b e r   a n d   s y m b o l  
         i f   ( p a s s w o r d . m a t c h ( / ( [ ! , @ , # , $ , % , ^ , & , * , ? , _ , ~ ] ) / )   & &   p a s s w o r d . m a t c h ( / ( [ 0 - 9 ] ) / ) )     s c o r e   + =   1 5    
          
         / / p a s s w o r d   h a s   c h a r   a n d   s y m b o l  
         i f   ( p a s s w o r d . m a t c h ( / ( [ ! , @ , # , $ , % , ^ , & , * , ? , _ , ~ ] ) / )   & &   p a s s w o r d . m a t c h ( / ( [ a - z A - Z ] ) / ) )     s c o r e   + =   1 5    
          
         / / p a s s w o r d   i s   j u s t   a   n u b e r s   o r   c h a r s  
         i f   ( p a s s w o r d . m a t c h ( / ^ \ w + $ / )   | |   p a s s w o r d . m a t c h ( / ^ \ d + $ / )   )     s c o r e   - =   1 0    
          
         / / v e r i f i n g   0   <   s c o r e   <   1 0 0  
         i f   (   s c o r e   <   0   )     s c o r e   =   0    
         i f   (   s c o r e   >   1 0 0   )     s c o r e   =   1 0 0    
          
         i f   ( s c o r e   <   3 4   )     r e t u r n   b a d P a s s    
         i f   ( s c o r e   <   6 8   )     r e t u r n   g o o d P a s s  
         r e t u r n   s t r o n g P a s s  
 }  
  
 f u n c t i o n   c h e c k R e p e t i t i o n ( p L e n , s t r )   {  
         r e s   =   " "  
         f o r   (   i = 0 ;   i < s t r . l e n g t h   ;   i + +   )   {  
                 r e p e a t e d = t r u e  
                 f o r   ( j = 0 ; j   <   p L e n   & &   ( j + i + p L e n )   <   s t r . l e n g t h ; j + + )  
                         r e p e a t e d = r e p e a t e d   & &   ( s t r . c h a r A t ( j + i ) = = s t r . c h a r A t ( j + i + p L e n ) )  
                 i f   ( j < p L e n )   r e p e a t e d = f a l s e  
                 i f   ( r e p e a t e d )   {  
                         i + = p L e n - 1  
                         r e p e a t e d = f a l s e  
                 }  
                 e l s e   {  
                         r e s + = s t r . c h a r A t ( i )  
                 }  
         }  
         r e t u r n   r e s  
 } 
