mirror of
https://github.com/LucasVbr/data-encryption-standard.git
synced 2026-05-13 17:12:10 +00:00
Ui Interface
This commit is contained in:
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ui.App">
|
||||||
|
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="20" y="20" width="500" height="400"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="9daab" class="javax.swing.JButton" binding="desButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Des"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<hspacer id="3812b">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</hspacer>
|
||||||
|
<vspacer id="acc45">
|
||||||
|
<constraints>
|
||||||
|
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
<component id="6cd6a" class="javax.swing.JButton" binding="tripleDesButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="TripleDes"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="4d39c" class="javax.swing.JButton" binding="quitterButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<background color="-12828863"/>
|
||||||
|
<enabled value="true"/>
|
||||||
|
<foreground color="-12828863"/>
|
||||||
|
<hideActionText value="false"/>
|
||||||
|
<text value="Quitter"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<hspacer id="8cfce">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</hspacer>
|
||||||
|
<component id="fb80b" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Application Des"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<vspacer id="6a02a">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package ui;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class App extends JFrame {
|
||||||
|
private JPanel mainPanel;
|
||||||
|
private JButton desButton, tripleDesButton, quitterButton;
|
||||||
|
|
||||||
|
public App() {
|
||||||
|
super("Projet Cryptographie");
|
||||||
|
|
||||||
|
this.add(mainPanel);
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
desButton.addActionListener(e -> new FenetreDes());
|
||||||
|
tripleDesButton.addActionListener(e -> new FenetreTripleDes());
|
||||||
|
quitterButton.addActionListener(e -> System.exit(0));
|
||||||
|
|
||||||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
this.setSize(400, 250);
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new App();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ui.FenetreDes">
|
||||||
|
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="20" y="20" width="500" height="400"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="a9395" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Message clair"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="72826" class="javax.swing.JTextField" binding="inputMsgClair">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="53911" class="javax.swing.JButton" binding="crypterButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Crypter"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="f854e" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Message crypté"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="e0e86" class="javax.swing.JTextField" binding="inputMsgCrypte">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="a3b5f" class="javax.swing.JButton" binding="decrypterButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Décrypter"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<vspacer id="2e16">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
<vspacer id="1def4">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
<vspacer id="6d5ec">
|
||||||
|
<constraints>
|
||||||
|
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package ui;
|
||||||
|
|
||||||
|
import cryptography.Des;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class FenetreDes extends JFrame {
|
||||||
|
private final Des des;
|
||||||
|
private JPanel mainPanel;
|
||||||
|
private JTextField inputMsgClair, inputMsgCrypte;
|
||||||
|
private JButton crypterButton, decrypterButton;
|
||||||
|
|
||||||
|
public FenetreDes() {
|
||||||
|
super("Des");
|
||||||
|
des = new Des();
|
||||||
|
|
||||||
|
this.add(mainPanel);
|
||||||
|
|
||||||
|
crypterButton.addActionListener(e -> {
|
||||||
|
String messageClair = inputMsgClair.getText();
|
||||||
|
try {
|
||||||
|
int[] messageCrypte = des.crypte(messageClair);
|
||||||
|
inputMsgCrypte.setText(Des.bitsToString(messageCrypte));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
new FenetreErreur("Impossible de crypter le message", this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
decrypterButton.addActionListener(e -> {
|
||||||
|
int[] messageCrypte = Des.stringToBits(inputMsgCrypte.getText());
|
||||||
|
try {
|
||||||
|
String messageClair = des.decrypte(messageCrypte);
|
||||||
|
inputMsgClair.setText(messageClair);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
new FenetreErreur("Impossible de décrypter le message", this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setSize(400, 250);
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package ui;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class FenetreErreur {
|
||||||
|
|
||||||
|
public FenetreErreur(String message, JFrame parent) {
|
||||||
|
final String TITLE = "Erreur";
|
||||||
|
JOptionPane.showMessageDialog(parent, message, TITLE, JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new FenetreErreur("Message", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ui.FenetreTripleDes">
|
||||||
|
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="20" y="20" width="500" height="400"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="216e9" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Message Clair"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="ac8e" class="javax.swing.JTextField" binding="inputMsgClair">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="c28d7" class="javax.swing.JButton" binding="crypterButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Crypter"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="f982c" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Message Crypté"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="3b648" class="javax.swing.JTextField" binding="inputMsgCrypte">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="d6dd4" class="javax.swing.JButton" binding="decrypterButton">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Decrypter"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<vspacer id="a8b11">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
<vspacer id="4663d">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
<vspacer id="e0141">
|
||||||
|
<constraints>
|
||||||
|
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package ui;
|
||||||
|
|
||||||
|
import cryptography.Des;
|
||||||
|
import cryptography.TripleDes;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class FenetreTripleDes extends JFrame {
|
||||||
|
private JPanel mainPanel;
|
||||||
|
private JTextField inputMsgClair, inputMsgCrypte;
|
||||||
|
private JButton crypterButton, decrypterButton;
|
||||||
|
|
||||||
|
private final TripleDes tripleDes;
|
||||||
|
|
||||||
|
public FenetreTripleDes() {
|
||||||
|
super("Triple Des");
|
||||||
|
tripleDes = new TripleDes();
|
||||||
|
|
||||||
|
this.add(mainPanel);
|
||||||
|
|
||||||
|
crypterButton.addActionListener(e -> {
|
||||||
|
String messageClair = inputMsgClair.getText();
|
||||||
|
try {
|
||||||
|
int[] messageCrypte = tripleDes.crypte(messageClair);
|
||||||
|
inputMsgCrypte.setText(Des.bitsToString(messageCrypte));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
new FenetreErreur("Impossible de crypter le message", this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
decrypterButton.addActionListener(e -> {
|
||||||
|
int[] messageCrypte = Des.stringToBits(inputMsgCrypte.getText());
|
||||||
|
try {
|
||||||
|
String messageClair = tripleDes.decrypte(messageCrypte);
|
||||||
|
inputMsgClair.setText(messageClair);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
new FenetreErreur("Impossible de décrypter le message", this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setSize(400, 250);
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user