The goal of this project is to write a simple encryption algorithm library to implement DES,ECB and CBC. The programming language is Java.
int[] DES(int[] plaintext, int[] key)
int[] ECB(String plaintext, String key)
int[] CBC(String plaintext, String key, String IV)
(1) DES
Input:
int[] plaintext = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1,
0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1,
1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1};
int[] key = { 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0,
0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0,
1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 0, 0, 1 };
Output:
int[] = ciphertext = { 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1,
0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1}
(2) ECB
Input:
String plaintext = “I LOVE SECURITY”;
String key = “ABCDEFGH”;
Output:
Int[] ciphertext = {198, 252, 213, 112, 106, 165, 23, 145,
29, 52, 125, 61, 85, 217, 102, 155};
Input:
String plaintext = “GO GATORS!”
String key = “ABCDEFGH”
Output:
Int[] ciphertext = {86, 100, 180, 248, 126, 142, 38, 5, 255,
224, 149, 93, 149, 189, 237, 2};
(3) CBC
Input:
String plaintext = “I LOVE SECURITY”;
String key = “ABCDEFGH”;
String IV = “ABCDEFGH”;
Output:
Int[] ciphertext = {63, 69, 76, 252, 154, 205, 193, 162, 46,
88, 102, 161, 151, 14, 56, 97};
Input:
String plaintext = “SECURITYSECURITY”;
String key = “ABCDEFGH”;
String IV = “ABCDEFGH”;
Output:
Int[] ciphertext = {232, 111, 39, 242, 85, 25, 41, 106, 39,
52, 175, 62, 196, 141, 176, 70};