Password Strength monitor in flex

Yesterday I spent hours writing my own password strength monitor utility in for a personal project but i couldn’t make it work properly, So i did exactly what every other developer does after getting thoroughly frustrated i.e.  I Googled until i reached this: geekWisdom winking

  • Download source from here
  • Click on the image to view sample

You can even use a text input validator which would give you  the similar result. Depends on the requirement … one can make it as  fancy as  the one mentioned above or as simple as a validator

below is the code for textInput validation

package co.uk.BetaDesigns.utils.string
{
public class PasswordStrength{
private static var _strength : Number = 0;
private static var _regSmall : RegExp = new RegExp( /([a-z]+)/ );
private static var _regBig : RegExp = new RegExp( /([A-Z]+)/ );
private static var _regNum    : RegExp = new RegExp( /([0-9]+)/ );
private static var _regSpecial : RegExp = new RegExp( /(\W+)/ );

public static function checkStrength( password : String ) : Number{
_strength = 0;
if( password.search( _regSmall ) != -1 ){
_strength ++;
}
if( password.search( _regBig ) != -1 ){
_strength ++;
}
if( password.search( _regNum ) != -1 ){
_strength ++;
}
if( password.search( _regSpecial ) != -1 ){
_strength ++;
}
return _strength;
}
public function PasswordStrength( se : SingletonEnforcer ){
//Force it so the user can’t get here;
}
}
}
class SingletonEnforcer{}

Share:
  • DZone
  • Digg
  • Twitter
  • Google Bookmarks
  • Technorati
  • StumbleUpon
  • MySpace
  • Sphinn
  • del.icio.us
  • Facebook
  • Reddit
  • Mixx

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Tags: , ,

One comment

  1. nice one

Leave a comment