hi all ..how are u ? i have a security project in java ...i have to implement the DES cipher and the Stream cipher ...with GUI ..where can i find a working source code for these ciphers ...can someone help plz ...and thnx in advance?

>where can i find a working source code for these ciphers ...

Why are looking here? It's there.

where?:S

where?:S

Dear Lazy,

I am saying that show your work first.

:D ah ok ......i will show my work ...i worked on the Asynchronous stream cipher ...but it dosen't work ...

import java.awt.*;
   import javax.swing.*;
   import java.awt.event.*;






           
   public class AStreamcipher extends JFrame{
           
   
      char [] tab={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
      JButton encrypt;
      JButton decrypt;
      JButton back;
      JTextField toenc;
      JTextField keyfield;
      JTextField res;
      JTextField todec;
      JTextField decrres;
      int key;
   
   
              
      public AStreamcipher () {
              
      
      
         create ();
      }
   
   
   
   
              
      public void create()
              
      
      
      {
      
         Container content=getContentPane();
         Color c1=new Color(48, 63, 120);
         content.setBackground(c1);
         content.setLayout(null);
      
         JLabel welcome=new JLabel();
         welcome.setBounds(500,4,500,50);
         welcome.setText("<html><body><font size=20 face=Andalus >Shift Cipher</font></body></html>");
         content.add(welcome);
      
         JLabel text=new JLabel();
         text.setBounds(120,200,200,100);
         text.setText("<html><body><font size=5 face=Andalus >Text To Encrypt</font></body></html>");
         content.add(text);
      
         toenc=new JTextField();
         toenc.setBounds(260,235,150,30);
         content.add(toenc);
      
         JLabel restext=new JLabel();
         restext.setBounds(120,342,200,100);
         restext.setText("<html><body><font size=5 face=Andalus >Encrypted Text</font></body></html>");
         content.add(restext);
      
         JLabel key1=new JLabel();
         key1.setBounds(520,160,50,20);
         key1.setText("<html><body><font size=5 face=Andalus >Key</font></body></html>");
         content.add(key1);
      
         keyfield=new JTextField();
         keyfield.setBounds(550,160,50,20);
         content.add(keyfield);
      
         res=new JTextField();
         res.setBounds(260,375,150,30);
         res.setEditable(false);
         content.add(res);
      
         encrypt=new JButton();
         encrypt.setText("Encrypt");
         encrypt.setForeground(c1);
         encrypt.setBounds(100,300,170,35);
         content.add(encrypt);
      
      
         encrypt.addActionListener(
                              
                              
                              
                              
                              
                              
                              
                                         
                                 new ActionListener()
                                         
                                 
                                 
                                 
                                 
                                 {
                                 
                                 
                                 
                                 
                                            
                                    public void actionPerformed(ActionEvent event)
                                            
                                    
                                    
                                    
                                    
                                    
                                    
                                    {
                                       try{
                                       
                                          String encres = "";
                                          key=Integer.parseInt(keyfield.getText());
                                          String temp=toenc.getText();
                                          char [] e;
                                          int encryptedtext=0;
                                          e=temp.toCharArray();
                                          int [] k =new int [e.length];
                                          k[0]=key;
                                          for(int i=0;i<temp.length();i++){
                                          
                                             for(int j=0;j<tab.length;j++){
                                                if(e[i] == tab[j]){
                                                   for(int s=1;s<k.length;s++){
                                                      k[s]=j;
                                                      //System.out.println(k[s] + "\n");
                                                   }
                                                }
                                             }
                                          }
                                          for(int t=0;t<k.length;t++)
                                             System.out.println(k[t] + "\n");
                                       
                                       
                                       }
                                       
                                       
                                       
                                       
                                       
                                                  
                                          catch (Exception e)
                                                  
                                          
                                          
                                          
                                          
                                          
                                          {
                                          }
                                    }
                                 }); 
      
         back=new JButton();
         back.setText("Back");
         back.setForeground(c1);
         back.setBounds(500,540,170,35);
         content.add(back);
      
      
         back.addActionListener(
                              
                              
                              
                              
                              
                              
                              
                                         
                                 new ActionListener()
                                         
                                 
                                 
                                 
                                 
                                 {
                                 
                                 
                                 
                                 
                                            
                                    public void actionPerformed(ActionEvent event)
                                            
                                    
                                    
                                    
                                    
                                    
                                    
                                    {
                                       try{
                                          Encryption1 e=new Encryption1();
                                          setVisible(false);
                                       }
                                       
                                       
                                                  
                                          catch (Exception e)
                                                  
                                          
                                          
                                          
                                          
                                          
                                          {
                                          }
                                    }
                                 }); 
      
      
      
      
      
      
      
         JLabel enctext=new JLabel();
         enctext.setBounds(750,200,200,100);
         enctext.setText("<html><body><font size=5 face=Andalus >Text To Decrypt</font></body></html>");
         content.add(enctext);
      
         todec=new JTextField();
         todec.setBounds(885,235,150,30);
         content.add(todec);
      
         JLabel resdec=new JLabel();
         resdec.setBounds(750,342,200,100);
         resdec.setText("<html><body><font size=5 face=Andalus >Decrypted Text</font></body></html>");
         content.add(resdec);
      
         decrres=new JTextField();
         decrres.setBounds(885,375,150,30);
         decrres.setEditable(false);
         content.add(decrres);
      
         decrypt=new JButton();
         decrypt.setText("Decrypt");
         decrypt.setForeground(c1);
         decrypt.setBounds(750,300,170,35);
         content.add(decrypt);
      
      
      
         decrypt.addActionListener(
                              
                              
                                         
                                 new ActionListener()
                                         
                                 
                                 
                                 {
                                 
                                            
                                    public void actionPerformed(ActionEvent event1)
                                            
                                    
                                    
                                    {
                                       try{
                                          key=Integer.parseInt(keyfield.getText());
                                          String decres = "";
                                       
                                          String temp=todec.getText();
                                          char [] p;
                                          int decryptedtext=0;
                                          p=temp.toCharArray();
                                          for(int i=0;i<p.length;i++){
                                             for(int j=0;j<tab.length;j++){
                                                if(p[i] == ' ')
                                                   decryptedtext= ' ';
                                                if(p[i] == tab[j]){
                                                   decryptedtext =(j - key)%26;
                                                   if(decryptedtext <0)
                                                      decryptedtext +=26;
                                                   //System.out.println(encryptedtext +"\n");
                                                   decres +=tab[decryptedtext];
                                                }
                                             
                                             }
                                          
                                          
                                          
                                          }
                                          decrres.setText(decres);
                                       
                                       }
                                       
                                       
                                       
                                       
                                                  
                                          catch (Exception e)
                                                  
                                          
                                          
                                          
                                          
                                          {
                                          }
                                    }
                                 }); 
      
      
      
      
         setTitle("Mozilla FireFox");
         setSize(1610,1600);
         setVisible(true);
      }
   
   
              
      public static void main(String []args){
              
      
      
         AStreamcipher e=new AStreamcipher();
      }
   }

but it's not working ...help me make it works ...thnx in advance

but for the synchronous stream cipher i did not know how to start :S

Use javax.crypto.Cipher class.

thnx but my dr wants me to implement the code ......:S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.