public static function evaluatePwd(sPW:String):int { if (sPW.length <= 4) return 0; var Modes:int = 0; for (var i:int = 0; i < sPW.length; i++) { Modes |= CharMode(sPW.charCodeAt(i)); }
return bitTotal(Modes);
function CharMode(iN:int):int { if (iN>=48 && iN <=57) return 1; if (iN>=65 && iN <=90) return 2; if (iN>=97 && iN <=122) return 4; else return 8; }
function bitTotal(num:int):* { var modes:int = 0; for (var i:int = 0; i < 4; i++) { if (num & 1) modes ++; num >>>= 1; } return modes; } }
public static function evaluatePwd(sPW:String):int { if (sPW.length <= 4) return 0; var Modes:int = 0; for (var i:int = 0; i < sPW.length; i++) { Modes |= CharMode(sPW.charCodeAt(i)); }
return bitTotal(Modes);
function CharMode(iN:int):int { if (iN>=48 && iN <=57) return 1; if (iN>=65 && iN <=90) return 2; if (iN>=97 && iN <=122) return 4; else return 8; }
function bitTotal(num:int):* { var modes:int = 0; for (var i:int = 0; i < 4; i++) { if (num & 1) modes ++; num >>>= 1; } return modes; } }另外还有一个十分简单的算法
public static function evaluatePwd2(sPW:String):int { return sPW.replace(/^(?:([a-z])|([A-Z])|([0-9])|(.)){5,}|(.)+$/g, “$1$2$3$4$5″).length; } public static function evaluatePwd2(sPW |