<script type="text/javascript"> //CharMode函數 //測試某個字符是屬于哪一類. function CharMode(iN){ if (iN>=48 && iN <=57) //數字 return 1; if (iN>=65 && iN <=90) //大寫字母 return 2; if (iN>=97 && iN <=122) //小寫 return 4; else return 8; //特殊字符 }
//bitTotal函數 //計算出當前密碼當中一共有多少種模式 function bitTotal(num){ modes=0; for (i=0;i<4;i++){ if (num & 1) modes++; num>>>=1; } return modes; }
//checkStrong函數 //返回密碼的強度級別
function checkStrong(sPW){ if (sPW.length<=4) return 0; //密碼太短 Modes=0; for (i=0;i<sPW.length;i++){ //測試每一個字符的類別并統計一共有多少種模式. Modes|=CharMode(sPW.charCodeAt(i)); }