Comunidad de diseño web y desarrollo en internet online

aplicacion en flex

Citar            
MensajeEscrito el 11 May 2010 02:25 pm
Hola:
Me dispongo a crear una pequeña aplicacion, se trata de meter un texto y que eligiendo el algoritmo te encriptacion te devuelva ese texto encriptado.
como lo puedo hacer para que quede graficamente "bonito"?? es decir ya dispongo del codigo para hacerlo, concretamente en java pero nose muy bien que utilizar para hacerlo en flex (mx:label, mx:form...)
aver si me podeis guiar, o algun ejemplo estaria bien.
yo he encontrado alguno:
http://rumkin.com/tools/cipher/caesar.php

Por yeayu

18 de clabLevel



 

firefox
Citar            
MensajeEscrito el 12 May 2010 12:50 am
Hola:
lo he hecho finalmente con <mx:Form> y algun que otro TextArea. Ha quedado bastante bien, aunque faltan algunos retoques.. si alguien está interesado en el codigo o algo que me lo diga por privado, aunque supongo que lo subiré cuando pueda
Un saludo

Por yeayu

18 de clabLevel



 

firefox
Citar            
MensajeEscrito el 12 May 2010 01:14 pm
Hola, estoy empezando en esto de flex y tengo el mismo caso que tú, domino bastante bien java y quiero integrarlo en una aplicación flex. Podrías mandarme el código a [email protected] para ver como queda?
muchas gracias :cool:

Por sincalzoncillo

0 de clabLevel



 

firefox
Citar            
MensajeEscrito el 16 May 2010 01:37 am
Asi quedo todo, a mi parecer bastante bien

Código ActionScript :

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="758" height="500" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FAFAFA, #626060]">
       <mx:Form width="418.5" height="264" x="30.5" y="24">
         <mx:FormHeading label="Encryption Application"  color="#06BFE7" width="375"/>
         <mx:FormItem label="Algorithm" width="346" height="106">
             <mx:RadioButton id="caesarBtn" label="Caesar Shift" selected="true"/>    
             <mx:RadioButton id="railBtn" label="Rail Fence" />    
             <mx:NumericStepper value="3" id="key" minimum="0" maximum="50"/>
         </mx:FormItem>
        <mx:FormItem label="Plain Text">
           <mx:TextInput id="plaintext" width="272"/>    
        </mx:FormItem>
        <mx:Button icon="@Embed(source='CANDADO.JPG')" click="myText.text=algorithm(railBtn.selected)" fillAlphas="[1.0, 1.0]" fillColors="[#F8F3F3, #E0DBDB]"/>
        <mx:FormItem label="encryption">
            <mx:TextArea id="myText" text="" width="272" height="22"/>     
        </mx:FormItem>
    </mx:Form>


     <mx:Script>
         <![CDATA[
         //SHIFT CIPHER
         private function getString(sentence:String, shift:Number):String{
            var s1:String = sentence; 
         //var alphabet:String = "abcdefghijklmnopqrstuvwxyz";
         var alphabet:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
         for (var i:int = 0; i< s1.length; i++) {
               var c:Array=new Array();
               c[0]=s1.charAt(i);
               var c1:String;
               if(c[0]!=" "){
            var x:int= alphabet.indexOf(c[0]);
            x=(x+shift)%26;
            c1=alphabet.charAt(x);}
            else
            c1=" ";
         s1 = s1.substring(0,i)+new String(c1)+ s1.substring(i+1);
         }
         return s1;
         }
         
         
         //RAIL FENCE
         private function railCipher(word:String, rows:Number, b:Boolean):String{
            var s2:String="";
            for (var y:int=0; y<word.length; y++)
            {
               if (word.charAt(y)!=" ")
                  s2 += word.charAt(y);
                  //now i have a String without spaces
           }
            var matrix:Array=new Array() 
         for (var k:int=0;k<s2.length;k++){ 
             var j:int=k/rows; 
             var i:int=k%rows;
             if (matrix[i]==null){ 
                matrix[i]=new Array() 
             }       
             matrix[i][j]=s2.charAt(k); 
         } 
         var text:String="";  
         for (i=0;i<matrix.length;i++){  
               text+=matrix[i].join(" ")+"\n";  
         }       
         var text2:String="";  
         for (i=0;i<matrix.length;i++){  
               text2+=matrix[i].join(""); 
         }
         if(b!=false)
         return text2;
         else       
            return text;
            
         }
        

         //call depend the algorithm selected
        private function algorithm(Caesar:Boolean):String    
            {
            var encryption:String;
            if (caesarBtn.selected)
               encryption=getString(plaintext.text, key.value);   
            else
                
               encryption=railCipher(plaintext.text, key.value, true);
            
            return encryption;    
         }
         //Information about Algorithm
         private function inforText(Caesar:Boolean):String
         {
            var textC:String;
            if(caesarBtn.selected){
            schema.visible=false;
            texto.visible=false;
            textC="The action of a Caesar cipher is to replace each plaintext letter with one a fixed number of places down the alphabet. This example is with a shift of three, so that a B in the plaintext becomes E in the ciphertext.";
            }
            else{
            texto.visible=true;
            schema.visible=true;
            textC="In the rail fence cipher, the plaintext is written downwards on successive rails of an imaginary fence, starting a new column when the bottom is reached. The message is then read off in rows.";
            }return textC;
         }
         ]]>

     </mx:Script>

     <mx:TextArea x="30" y="312" width="364.5" height="111" text="{inforText(caesarBtn.selected)}" editable="false"/>
     <mx:Text x="30" y="296" width="109" text="Information:"/>
     <mx:TextArea width="106.5" height="93" id="schema" visible="false" text="{railCipher(plaintext.text, key.value, false)}" editable="false" x="476" y="178"/>
     <mx:Label x="476" y="162" text="Schema Rail Fence" id="texto" visible="false" width="118.5"/>
</mx:Application>

Por yeayu

18 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.