<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:Style>Application {fontSize:12px;}</mx:Style><mx:Script><![CDATA[//密碼層級驗證 private function pwdInputVis():void{ if(txtPassword.text == ""){ levelOne.opaqueBackground = "16777215"; levelTwo.opaqueBackground = "16777215"; levelThree.opaqueBackground = "16777215"; levelFour.opaqueBackground = "16777215"; levelFive.opaqueBackground = "16777215"; levelSix.opaqueBackground = "16777215"; levelSeven.opaqueBackground = "16777215"; return; } var num:Number = pwdStrengthCheck(txtPassword.text); levelOne.opaqueBackground = "16777215"; levelTwo.opaqueBackground = "16777215"; levelThree.opaqueBackground = "16777215"; levelFour.opaqueBackground = "16777215"; levelFive.opaqueBackground = "16777215"; levelSix.opaqueBackground = "16777215"; levelSeven.opaqueBackground = "16777215"; if(num >= 90){ levelSeven.opaqueBackground = "39423"; } else if(num >= 80){ levelSix.opaqueBackground = "6736896"; } else if(num >= 70){ levelFive.opaqueBackground = "65280"; } else if(num >= 60){ levelFour.opaqueBackground = "16776960"; } else if(num >= 50){ levelThree.opaqueBackground = "16763904"; } else if(num >= 25){ levelTwo.opaqueBackground = "16724736"; } else if(num >= 0){ levelOne.opaqueBackground = "16711680"; } } //密碼得分計算 static public function pwdStrengthCheck(passStr:String):uint{if(!passStr)return 0;var count:uint = 0;count += passStr.length<=4?5:(passStr.length>=8?25:10);count += !passStr.match(/[a-z]/i)?0:(passStr.match(/[a-z]/) && passStr.match(/[A-Z]/)?20:10);count += !passStr.match(/[0-9]/)?0:(passStr.match(/[0-9]/g).length >= 3?20:10);count += !passStr.match(//W/)?0:(passStr.match(//W/g).length > 1?25:10);count += !passStr.match(/[0-9]/)||!passStr.match(/[a-z]/i)?0:(!passStr.match(//W/)?2:(!passStr.match(/[a-z]/) || !passStr.match(/[A-Z]/)?3:5));return count;} private function showPwdText():void{if(cboShow.selected){txtPassword.displayAsPassword = false;}else{txtPassword.displayAsPassword = true;}}]]></mx:Script> <mx:Panel width="450" height="450" layout="absolute" horizontalCenter="0" verticalCenter="0" title="密碼層級驗證"><mx:Label text="密碼" x="10" y="12"/><mx:TextInput x="47" y="10" displayAsPassword="true" width="240" change="pwdInputVis();" id="txtPassword" editable="true"/><mx:HRule x="0" y="48" width="100%"/><mx:Label x="6" y="58" text="非常弱" width="60" textAlign="center" id="levelOne"/><mx:Label x="65" y="58" text="弱" width="60" textAlign="center" id="levelTwo"/><mx:Label x="124" y="58" text="一般" width="60" textAlign="center" id="levelThree"/><mx:Label x="183" y="58" text="強" width="60" textAlign="center" id="levelFour"/><mx:Label x="242" y="58" text="非常強" width="60" textAlign="center" id="levelFive"/><mx:Label x="301" y="58" text="安全" width="60" textAlign="center" id="levelSix"/><mx:Label x="360" y="58" text="非常安全" width="60" textAlign="center" id="levelSeven"/><mx:TextArea x="10" y="96" width="410" height="302" enabled="true" wordWrap="true" editable="false"><mx:text><![CDATA[來自 Google 的密碼強度評分標準 一、密碼長度:•5 分: 小於等於 4 個字元•10 分: 5 到 7 字元•25 分: 大於等於 8 個字元 二、字母:•0 分: 沒有字母•10 分: 全都是小(大)寫字母•20 分: 大小寫混合字母 三、數字:•0 分: 沒有數字•10 分: 1 個數字•20 分: 大於等於 3 個數字 四、符號:•0 分: 沒有符號•10 分: 1 個符號•25 分: 大於 1 個符號 五、獎勵:•2 分: 字母和數字•3 分: 字母、數字和符號•5 分: 大小寫字母、數字和符號 最後的評分標準:•>= 90: 非常安全•>= 80: 安全(Secure)•>= 70: 非常強•>= 60: 強(Strong)•>= 50: 一般(Average)•>= 25: 弱(Weak)•>= 0: 非常弱]]></mx:text></mx:TextArea><mx:HRule x="0" y="86" width="100%"/><mx:CheckBox x="295" y="10" label="顯示密碼明文" id="cboShow" selected="false" click="showPwdText();"/></mx:Panel> </mx:Application>