Rumus 3. Running Time
waktu akhir = waktu yang diambil dari akhir proses enkripsi atau dekripsi.
waktu awal = waktu yang diambil sebelum melakukan enkripsi atau dekripsi.
b. Avalanche Effect
Avalanche effect adalah salah satu karakteristik yang menjadi acuan untuk menentukan baik atau tidaknya sebuah algoritma kriptografi yaitu perubahan sebuah bit pada plaintext atau kunci yang dapat menghasilkan perubahan beberapa bit dari ciphertext.
24
3.4. Desain Alat Uji
1. Flowchart Running Time Enkripsi
25 3. Flowchart Avalanche Effect
26
BAB IV
PENGUJIAN DAN ANALISIS
Untuk melakukan evaluasi terhadap unjuk kerja algoritma DES, 3DES, AES, Blowfish dan Twofish, maka dilakukan pengujian dengan menggunakan rancangan skenario yang sudah dijelaskan pada Bab III, Data diperoleh dari output yang dihasilkan ketika sistem berlangsung dan kemudian menjadi bahan untuk dilakukan analisis. Setelah melakukan pengujian program enkripsi dan dekripsi maka didapatkan hasil sebagai berikut :
4.1. Hasil Pengujian Sistem
4.1.1. Perbandingan Running Time proses enkripsi.
Grafik 1. Perbandingan Runtime Enkripsi
Pada grafik 1 menunjukkan perbandingan running time saat melakukan enkripsi data. algoritma twofish dapat melakukan proses enkripsi lebih cepat dari algoritma
1549 2000 1580 1877 225 2767 4113 2085 2385 2300 4121 7367 2832 3164 2441 0 1000 2000 3000 4000 5000 6000 7000 8000
DES TDES AES BLOWFISH TWOFISH
ENKRIPSI
1 MB 25 MB 50 MB
27 lainnya pada size dokumen 1MB yaitu 225ms. Sedangkan pada algoritma lainnya mendapat waktu diatas 1000ms. 3DES pada size 50MB mencatat waktu paling lama dari yang lain yaitu mencapai 7367 ms.
4.1.2. Perbandingan Running Time proses dekripsi
Grafik 2. Perbandingan Runtime Dekripsi
Pada grafik 2 menunjukkan perbandingan running time saat melakukan dekripsi data. Waktu yang dibutuhkan untuk melakukan dekripsi tidak terlalu berbeda dari enkripsi, karena algoritma diatas menggunakan kunci simetris. Algoritma twofish mendapat waktu paling cepat pada ukuran 1MB yaitu 465ms. Dan 3DES membutuhkan waktu yang lebih lama dari algoritma lainnya.
1681 2100 1971 1857 465 2720 4833 2067 2165 2440 4238 7060 2219 2972 2374 0 1000 2000 3000 4000 5000 6000 7000 8000
DES TDES AES BF TF
DEKRIPSI
1 MB 25 MB 50 MB
28 4.1.3. Perbandingan Avalanche kunci.
Grafik 3. Perbandingan Avalanche Kunci
Avalanche Kunci
DES TDES AES BLOWFISH TWOFISH
Variasi 1 huruf 30,55 32,87 35,18 36,11 33,33 Variasi 2 huruf 35,64 36,57 40,74 31,01 32,87 Variasi 3 huruf 30,09 35,18 31,94 30,55 30,55
variasi DES TDES AES BLOWFISH TWOFISH
1 huruf 66/216 71/216 76/216 78/216 72/216
2 huruf 77/216 79/216 88/216 67/216 71/216
3 huruf 65/216 76/216 69/216 66/216 66/216
pesan key Variasi Key
Advensius Putra MyKey
MyKee MyKit MyHop Tabel 1. Avalanche Effect Kunci
Pada tabel 1. Menunjukkan perbandingan avalanche effect dari kunci. Pada variasi 1 huruf, algoritma Blowfish menghasilkan avalanche paling besar yaitu 36,11% dengan perubahan bit 78 dari total bit 216. Pada variasi 2 huruf algoritma AES menghasilkan avalanche paling besar yaitu 40,74% dengan perubahan bit 88 dari 216 bit. Pada variasi 3 huruf algoritma 3DES menghasilkan avalache paling besar yaitu 35,18% dengan perubahan bit 76 dari 216 bit. Namun jika dirata-rata dari
30,55 32,87 35,18 36,11 33,33 35,64 36,57 40,74 31,01 32,87 30,09 35,18 31,94 30,55 30,55 0 5 10 15 20 25 30 35 40 45
DES TDES AES BLOWFISH TWOFISH
Per sen tase ( % )
Avalanche Kunci
Variasi 1 huruf Variasi 2 huruf Variasi 3 huruf29 semua variasi kunci yang ada, algoritma AES mendapatkan avalache yang paling besar yaitu 35,9%.
4.1.4. Perbandingan Avalanche pesan.
Grafik 4. Perbandingan Avalanche Pesan
Avalanche Pesan
DES TDES AES BLOWFISH TWOFISH
Variasi 1 huruf 15,27 19,9 34,72 17,59 30,55
Variasi 2 huruf 12,96 15,74 34,25 17,59 28,7
Variasi 3 huruf 16,66 18,05 32,4 19,44 24,07
variasi DES TDES AES BLOWFISH TWOFISH
1 huruf 33/216 43/216 75/216 38/216 66/216
2 huruf 28/216 34/216 74/216 38/216 62/216
3 huruf 36/216 39/216 70/216 42/216 52/216
key Pesan Variasi Pesan
MyKey Advensius Putra
Advensius Putri Advensius Putlo Advensius Punce Tabel 2. Avalanche Effect Pesan
15,27 19,9 34,72 17,59 30,55 12,96 15,74 34,25 17,59 28,7 16,66 18,05 32,4 19,44 24,07 0 5 10 15 20 25 30 35 40
DES TDES AES BLOWFISH TWOFISH
Per sen tase ( % )
Avalanche Pesan
Variasi 1 huruf Variasi 2 huruf Variasi 3 huruf30 Pada tabel 2. Menunjukkan perbandingan avalanche effect dari pesan. Pada variasi 1 huruf, algoritma AES menghasilkan avalanche paling besar yaitu 34,72% dengan perubahan bit 75 dari total bit 216. Pada variasi 2 huruf algoritma AES menghasilkan avalanche paling besar yaitu 34,25% dengan perubahan bit 74 dari 216 bit. Pada variasi 3 huruf algoritma AES menghasilkan avalache paling besar yaitu 32,4% dengan perubahan bit 70 dari 216 bit. Pada avalanche pesan perbandingan algoritma AES dengan yang lainnya sangatlah besar.
31
BAB V
KESIMPULAN DAN SARAN
5.1 KESIMPULAN
Setelah dilakukan anailis oleh penulis, didapat kesimpulan bahwa semakin besar ukuran data yang akan dienkripsi maka running time akan semakin lama. Perubahan bit kunci sangat mempengaruhi isi cipherteks, sehingga avalanche yang dihasilkan oleh perubahan kunci dapat mengakibatkan perubahan bit yang besar. Pada avalanche kunci bit yang terjadi jika salah satu hurufnya lebih besar dari avalanche pesan, penulis menyimpulkan bahwa variasi dari kunci lebih berpengaruh dari perubahan bit dari ciphertext daripada variasi dari pesan, karena pengacakan data pesan diacak berdasarkan ekspansi kuncinya. Dan untuk hasil pengujian kali ini algoritma AES lebih baik dari algoritma lainnya dari semua parameter unjuk kerja yang di ujikan. AES memiliki persentase lebih besar untuk avalanche effect dari algoritma lainnya.
5.2 SARAN
Untuk algoritma DES penyandian sangat sederhana dan pola dapat diukur dengan komputer modern, sedangkan algoritma 3DES membutuhkan waktu yang lama dalam melakukan enkripsi. Penulis menyarankan untuk menggunakan algoritma enkripsi yang sudah diperbarui dan dapat digunakan sesuai kebutuhan kita dalam mengamankan data. AES dan Blowfish sama-sama baik dalam metode penyandian. Semoga untuk penelitian selanjutnya dapat memberikan perbandingan unjuk kerja dari semua algoritma kriptografi.
32
DAFTAR PUSTAKA
[1] https://id.wikipedia.org/wiki/Kriptografi
[2] Munir, Rinaldi., “ Bahan Kuliah IF3058 Kriptografi.”, Program Studi Informatika, Institut Teknologi Bandung, 2009.
[3] Riyanto, M.Zaki., “Mengenal Kriptografi : Ilmu Pengamanan Rahasia Berbasis Matematika”, Prodi Matematika, Universitas Islam Negri Sunan Kalijaga, Yogyakarta, 2018.
[4] National Institute of Standards and Technology, Data Encryption Standard, FIPS PUB 46-3, U.S. Department of Commerce, October1999.
[5] Charles H. Bennett, Gilles Brassard, \Quantum Cryptography: Pu-blic Key Distribution and Coin Tossing," International Conference on Computers, Systems and Signal Processing, 1984.
33 LAMPIRAN
1. Code DES
Generate key DES public class GenerateKeyDES {
static Key generateKey(String kunciEnkripsi) throws Exception {
Key key = new SecretKeySpec(KonversiByte.konversiKeByte(kunciEnkripsi), "DES");
return key; }
static class KonversiByte {
static byte[] konversiKeByte(String kunci) { byte[] array_byte = new byte[8];
int i = 0;
while (i < kunci.length()) {
array_byte[i] = (byte) kunci.charAt(i); i++; } if (i < 8) { while (i < 8) { array_byte[i] = (byte) i; i++; } } return array_byte; } } } Enkripsi DES public class EncryptDES {
public static String encryptDES(String Data, String kunciEnkripsi) throws Exception {
Cipher c = Cipher.getInstance("DES");
Key key = GenerateKeyDES.generateKey(kunciEnkripsi); c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(Data.getBytes("UTF-8"));
String encryptedValue = DatatypeConverter.printBase64Binary(encVal); return encryptedValue;
} }
34 Dekripsi DES
public class DecryptDES {
public static String decryptDES(String encryptedData, String kunciEnkripsi) throws Exception {
Cipher c = Cipher.getInstance("DES");
Key key = GenerateKeyDES.generateKey(kunciEnkripsi); c.init(Cipher.DECRYPT_MODE, key);
byte[] decordedValue = DatatypeConverter.parseBase64Binary(encryptedData); byte[] decValue = c.doFinal(decordedValue);
String decryptedValue = new String(decValue); return decryptedValue;
} }
2. Code 3DES
Generate key 3DES public class GenerateKeyDESede {
static Key generateKey(String kunciEnkripsi) throws Exception {
Key key = new SecretKeySpec(KonversiByte.konversiKeByte(kunciEnkripsi), "DESede");
return key; }
static class KonversiByte {
static byte[] konversiKeByte(String kunci) { byte[] array_byte = new byte[24]; int i = 0;
while (i < kunci.length()) {
array_byte[i] = (byte) kunci.charAt(i); i++; } if (i < 24) { while (i < 24) { array_byte[i] = (byte) i; i++; } } return array_byte; } } } Enkripsi 3DES public class EncryptDESede {
public static String encryptDESede(String Data, String kunciEnkripsi) throws Exception {
Cipher c = Cipher.getInstance("DESede");
35 c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(Data.getBytes("UTF-8"));
String encryptedValue = DatatypeConverter.printBase64Binary(encVal); return encryptedValue;
} }
Dekripsi 3DES public class DecryptDESede {
public static String decryptDESede(String encryptedData, String kunciEnkripsi) throws Exception {
Cipher c = Cipher.getInstance("DESede");
Key key = GenerateKeyDESede.generateKey(kunciEnkripsi); c.init(Cipher.DECRYPT_MODE, key);
byte[] decordedValue = DatatypeConverter.parseBase64Binary(encryptedData); byte[] decValue = c.doFinal(decordedValue);
String decryptedValue = new String(decValue); return decryptedValue;
} }
3. Code AES
Generate key AES public class GenerateKeyAES {
static Key generateKey(String kunciEnkripsi) throws Exception {
Key key = new SecretKeySpec(KonversiByte.konversiKeByte(kunciEnkripsi), "AES");
return key; }
static class KonversiByte {
static byte[] konversiKeByte(String kunci) { byte[] array_byte = new byte[16]; int i = 0;
while (i < kunci.length()) {
array_byte[i] = (byte) kunci.charAt(i); i++; } if (i < 16) { while (i < 16) { array_byte[i] = (byte) i; i++; } } return array_byte; } } }
36 Enkripsi AES
public class EncryptAES {
public static String encryptAES(String Data, String kunciEnkripsi) throws Exception {
Cipher c = Cipher.getInstance("AES");
Key key = GenerateKeyAES.generateKey(kunciEnkripsi); c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(Data.getBytes("UTF-8"));
String encryptedValue = DatatypeConverter.printBase64Binary(encVal); return encryptedValue;
} }
Dekripsi AES public class DecryptAES {
public static String decryptAES(String encryptedData, String kunciEnkripsi) throws Exception {
Cipher c = Cipher.getInstance("AES");
Key key = GenerateKeyAES.generateKey(kunciEnkripsi); c.init(Cipher.DECRYPT_MODE, key);
byte[] decordedValue = DatatypeConverter.parseBase64Binary(encryptedData); byte[] decValue = c.doFinal(decordedValue);
String decryptedValue = new String(decValue); return decryptedValue;
} }
4. Code Blowfish
Generate key Blowfish public class GenerateKeyBlowfish {
static Key generateKey(String kunciEnkripsi) throws Exception {
Key key = new SecretKeySpec(KonversiByte.konversiKeByte(kunciEnkripsi), "Blowfish");
return key; }
static class KonversiByte {
static byte[] konversiKeByte(String kunci) { byte[] array_byte = new byte[16]; int i = 0;
while (i < kunci.length()) {
array_byte[i] = (byte) kunci.charAt(i); i++; } if (i < 16) { while (i < 16) { array_byte[i] = (byte) i; i++; } }
37 return array_byte; } } } Enkripsi Blowfish public class EncryptBlowFish {
public static String encryptBlowfish(String Data, String kunciEnkripsi) throws Exception {
Cipher c = Cipher.getInstance("Blowfish");
Key key = GenerateKeyBlowfish.generateKey(kunciEnkripsi); c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(Data.getBytes("UTF-8"));
String encryptedValue = DatatypeConverter.printBase64Binary(encVal); return encryptedValue;
} }
Dekripsi Blowfish public class DecryptBlowFish {
public static String decryptBlowfish(String encryptedData, String kunciEnkripsi) throws Exception {
Cipher c = Cipher.getInstance("Blowfish");
Key key = GenerateKeyBlowfish.generateKey(kunciEnkripsi); c.init(Cipher.DECRYPT_MODE, key);
byte[] decordedValue = DatatypeConverter.parseBase64Binary(encryptedData); byte[] decValue = c.doFinal(decordedValue);
String decryptedValue = new String(decValue); return decryptedValue;
} }
5. CodeTwofish
Generate key Twofish public class GenerateKeyTwofish {
static class KonversiByte {
static byte[] konversiKeByte(String kunci) { byte[] array_byte = new byte[16]; int i = 0;
while (i < kunci.length()) {
array_byte[i] = (byte) kunci.charAt(i); i++; } if (i < 16) { while (i < 16) { array_byte[i] = (byte) i; i++; } }
38 return array_byte; } } } Enkripsi Twofish public class EncryptTwofish {
public static String encryptTwofish(String cookieValue, String key) throws InvalidKeyException, UnsupportedEncodingException {
byte[] plainText; byte[] encryptedText;
Twofish twofish = new Twofish(); // ekspansi kunci
Object keyObject = twofish.makeKey(konversiKeByte(key), 16); //membuat ukuran blok dengan 16 byte
if ((cookieValue.length() % 16) != 0) { while ((cookieValue.length() % 16) != 0) { cookieValue += " "; } } // inisialisasi plainteks/ciphertext plainText = cookieValue.getBytes("UTF-8"); encryptedText = new byte[cookieValue.length()]; // proses enkripsi
for (int i = 0; i < Array.getLength(plainText); i += 16) {
twofish.encrypt(plainText, i, encryptedText, i, keyObject, 16); }
String encryptedString = DatatypeConverter.printBase64Binary(encryptedText); return encryptedString;
} }
Dekripsi Twofish public class DecryptTwofish {
public static String decryptTwofish(String cookieValue, String key) throws InvalidKeyException, UnsupportedEncodingException {
byte[] encryptedText; byte[] decryptedText;
Twofish twofish = new Twofish(); //ekpansi kunci
Object keyObject = twofish.makeKey(konversiKeByte(key), 16); //panjang ukuran blok
if ((cookieValue.length() % 16) != 0) { while ((cookieValue.length() % 16) != 0) { cookieValue += " ";
} }
//inisialisasi array plainteks/ciphertext
encryptedText = DatatypeConverter.parseBase64Binary(cookieValue); decryptedText = new byte[cookieValue.length()];
//iterasi
39 twofish.decrypt(encryptedText, i, decryptedText, i, keyObject, 16);
}
String decryptedString = new String(decryptedText, "UTF-8"); return decryptedString;
} }
6. Code Avalanche Effect
Konversi Biner public class KonversiBiner {
public static String toBinary(String s) { String temp = s;
byte[] bytes = s.getBytes(); for (byte b : bytes) { }
StringBuilder binary = new StringBuilder(); for (byte b : bytes) {
int val = b;
for (int i = 0; i < 8; i++) {
binary.append((val & 128) == 0 ? 0 : 1); val <<= 1; } binary.append(' '); } return binary.toString(); } } Hamming Distance public class HammingDistance {
public static int hamDist (String str1, String str2) { int i = 0, count = 0; while (i < str1.length()) { if (str1.charAt(i) != str2.charAt(i)) { count++; } i++; } return count; } }