<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="600" viewSourceURL="srcview/index.html">
<mx:Script>
    <![CDATA[
        import com.tvds.*;
        
        [Bindable]private var EncrypTypes:Array = ["MD5", "SHA1", "SHA-256"];
        
        /**
         * @param the String which is to be encrypted
         * @return an encrypted version of the source parameter
         * 
         */           
        public function EncryptIt(strPW:String, EncType:String, Salt:Boolean, SaltNr:Number):void
        {
            //lblOutput.text = Encryption.encrypt(strPW,Encryption.CRYPTIT_SHA256, chrSalt.selected, 8);
            lblOutput.text = Encryption.encrypt(strPW, EncType, Salt, SaltNr);
        }

        /**
         * @param the String which is to be checked on encrypted password
         * @param the encrypted password
         * @return true or false
         */         
        public function CheckCryptIt(strPW:String, encrPW:String, EncType:String, Salt:Boolean):void
        {
            chkChecked.selected = Encryption.CheckCrypt(strPW,encrPW, EncType, Salt);
        }
        
                
    ]]>
</mx:Script>
    <mx:Panel layout="absolute" left="5" right="5" top="5" bottom="5" title="Password Encrypter and Checker">
        <mx:Text y="8" text="Put in a password, select or deselect &quot;Use Salt&quot; and press Encrypt.&#xa;You will see the encrypted password (with or without Salt) appear." left="10" right="10"/>
        <mx:Label x="10" y="45" text="Password"/>
        <mx:TextInput x="74" y="45" id="txtPassword"/>
        <mx:CheckBox x="242" y="45" label="Use Salt" id="chrSalt"/>
        <mx:ComboBox x="321" y="45" id="cmbEncryptor" dataProvider="{EncrypTypes}" />
        <mx:Button x="429" y="45" label="Encrypt" click="EncryptIt(txtPassword.text, cmbEncryptor.selectedItem.toString(), chrSalt.selected, 8);"/>
        <mx:Text x="10" y="71" text="Outcome:&#xa;In the label below you will see a encrypted password"/>
        <mx:Label y="118" id="lblOutput" left="10" right="10" selectable="true"/>
        

        <mx:Text y="144" text="Put in a second password, can be the same as above, or different. It depends on if you like to see if this works.&#xa;The encrypted outcome of above will be checked on a new password.&#xa;Press Check." left="10" right="10"/>
        <mx:Label x="10" y="204" text="Password"/>
        <mx:TextInput x="74" y="202"  id="txtPassword1"/>
        <mx:Button x="439" y="202" label="Check" click="CheckCryptIt(txtPassword1.text, lblOutput.text, cmbEncryptor.selectedItem.toString(), chrSalt.selected);"/>
        <mx:Text x="10" y="232" text="Outcome:"/>
        <mx:CheckBox x="10" y="247" label="Same as encrypted Password" enabled="true" id="chkChecked"/>
        <mx:ControlBar>
        </mx:ControlBar>
    </mx:Panel>

    
</mx:Application>