-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
42 lines (34 loc) · 1.26 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Algorithm.Bits;
import Algorithm.DES;
import Algorithm.Key;
import Algorithm.Message;
import java.util.Arrays;
/**
* 03.10.2018 | created by Lukas S
*/
public class Main {
public static void main(String[] args) {
String hex = Bits.stringToHex("Hello World!");
//hex = 48 65 6C 6C 6F 20 57 6F 72 6C 64 21
Message msg = new Message(hex);
System.out.println("Message { " + msg.toString() + " }");
System.out.println(Arrays.toString(msg.getData()));
for (int i = 0; i < msg.getBlockCount(); i++) {
System.out.println(Arrays.toString(msg.getBlock(i)));
}
Key key = new Key("6D62B676B5F7B932");
//Encrypt
DES des = new DES();
Message enc = des.encrypt(msg, key);
System.out.println("Encoded { " + enc.toString() + " }");
for (int i = 0; i < enc.getBlockCount(); i++) {
System.out.println(Arrays.toString(enc.getBlock(i)));
}
//Decrypt
Message dec = des.decrypt(enc, key);
System.out.println("Decoded { " + dec.toString() + " }");
for (int i = 0; i < dec.getBlockCount(); i++) {
System.out.println(Arrays.toString(dec.getBlock(i)));
}
}
}