TXT
TXT
principale;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
//By Samirdine
//By Radika
//By Seifoudine
j = ++j % key.length();
}
return encrypted;
}
public static String decryptVigenere(String message, String key) {
String decrypt = "";
message = message.toUpperCase();
key = key.toUpperCase();
key.split("");
int j = 0;
return decrypt;
}
Container a=f.getContentPane();
//champs 1: exploitation
JLabel l3=new JLabel("Texte claire:");
l3.setBounds(19,40,400,50);
a.add(l3);
//champs 2: code
JLabel l2=new JLabel("Clef:");
l2.setBounds(50,180,400,50);
a.add(l2);
//champs3: exploitation
JLabel l=new JLabel("Texte chiffré:");
l.setBounds(20,200,100,50);
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
int userSelection = fileChooser.showSaveDialog(f);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileToSave = fileChooser.getSelectedFile();
}
}
});
// fin
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String k = t1.getText();
String z = t3.getText();
String res = encryptVigenere(k,z);
t2.setText(res);
}
});
@Override
public void actionPerformed(ActionEvent e) {
String k = t1.getText();
String z = t3.getText();
@Override
public void actionPerformed(ActionEvent e) {
t1.setText("");
t1.enable();
t2.setText("");
t3.setText("");
}
});
@Override
public void actionPerformed(ActionEvent e) {
t1.setText(t2.getText());
t2.setText("");
}
});
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b3) {
int returnVal = fc.showOpenDialog(b2);
if (returnVal == JFileChooser.APPROVE_OPTION) {
FileReader in = null;
try {
//OutputStream os = new FileOutputStream("");
in = new FileReader(file);
} catch (FileNotFoundException e2) {
e2.printStackTrace();
}
try {
in = new FileReader(file.getAbsolutePath());
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
int c = 0;
try {
StringBuffer sb = new StringBuffer();
char de;
while((c = in.read())!=-1){
de = (char)c;
System.out.print(de );
sb.append(de);
t1.setText(sb.toString());
t1.disable();
e1.printStackTrace();
}
}
else {
t2.setText("Annulation du lecture de
fichier." );
}
}
});
a.add(l);
try {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
f.setVisible(true);