Kompleksitas Algoritma IMPLEMENTASI DAN PENGUJIAN SISTEM

memakan waktu lebih lama dibandingkan dengan proses kompresi dengan rata-rata waktu kompresi 5,372s dan waktu dekompresi 11,794s. Tabel 4.5. Hasil Pengujian Proses Kompresi Cipherteks3 No Ukuran File sblm Kompresi KB Ukuran File stlh Kompresi KB Waktu Kompresi s Waktu Dekompresi s RC CR Rd 1 2,57 1,35 1,716 3,996 2,18 45,871 54,128 2 3,45 1,81 2,305 5,347 2,171 46,053 53,946 3 3,87 2,20 2,822 6,811 2,003 49,913 50,086 4 6,14 3,21 4,226 9,214 2,181 45,838 54,161 5 8,23 4,32 5,326 12,483 2,174 46,01 53,989 6 9,23 5,25 6,418 14,401 2,007 49,837 50,162 7 9,5 4,97 6,393 14,441 2,182 45,837 54,162 8 12,7 6,69 8,782 18,807 2,173 46,012 53,987 9 14,2 8,13 10,059 22,376 2,006 49,84 50,159 Rata-rata 5,538 11,986 2,119 47,245 52,753 Tabel 4.5 merupakan hasil dari pengujian kompresi file Cipherteks3 yang didapatkan dari proses Dekripsi1. Sebagaimana terlihat pada tabel, proses dekompresi teks memakan waktu lebih lama dibandingkan dengan proses kompresi dengan rata-rata waktu kompresi 5,538s dan waktu dekompresi 11,986s.

4.4 Kompleksitas Algoritma

4.4.1 Kompleksitas algoritma Massey-Omura Pengujian kompleksitas algoritma dilakukan untuk mengetahui tingkat nilai masukan n suatu algoritma. Kompleksitas algoritma dihitung berdasarkan kode program sistem. Kompleksitas algoritma Massey-Omura ditunjukkan pada Tabel 4.8. Tabel 4.6. Kompleksitas Algoritma Massey-Omura Kode Program � � � 1 public static BigInteger gcdBigInteger m, BigInteger n{ 2 BigInteger r = m n; � 1 1 � 1 3 while r = 0 { � 2 � � 2 � 4 return gcdn,r; � 3 � � 3 � 5 } 6 return n � 3 1 � 3 7 } 8 public static int kunci_eAint prima{ 9 Random rnd = new Random; � 1 1 � 1 10 int key_eA = rnd.Next2, prima-1; � 1 1 � 1 Universitas Sumatera Utara 11 if gcdkey_e, prima - 1 == 1 � 4 1 � 4 12 return key_e � 3 1 � 3 13 else 14 return kunci_e prima; � 3 1 � 3 15 } 16 public static int kunci_dAint prima, BigInteger e{ 17 int key_dA = 1; � 1 1 � 1 18 if gcde, prima - 1 == 1{ � 4 1 � 4 19 BigInteger hasil = key_de prima-1; � 1 1 � 1 20 while hasil = 1 hasil = 0{ � 2 � � 2 � 21 d++; � 6 � � 6 � 22 hasil = key_de prima-1; � 1 � � 1 � 23 } 24 if hasil == 0 � 5 1 � 5 25 return kunci_dprima, e; � 3 1 � 3 26 else 27 return key_d; � 3 1 � 3 28 } 29 else 30 return kunci_dprima, e; � 3 1 � 3 31 } 32 public static string enkripsistring Plain, int pr ima, int e{ 33 string plain = ; � 1 1 � 1 34 BigInteger[] p = new BigInteger[50000]; � 1 1 � 1 35 string text = ; � 1 1 � 1 36 string[] bitsplain = Plain. Split ; � 1 1 � 1 37 foreach char c in plaintxt{ � 5 � � 5 � 38 plain += System.Convert. ToInt32c.ToString+ ; � 6 � � 6 � 39 } 40 string[] bitsplain = plain. Split ; � 1 1 � 1 41 for int i=0; ibitsplain.Length-1; i++{ � 7 � � 7 � 42 p[i]=Convert. ToInt32bitsplain[i]; � 1 � � 1 � 43 BigInteger c1x = BigInteger. Powc1[i],e prima; � 1 � � 1 � 44 text += Convert. ToStringc+ ; � 6 � � 6 � 45 } 46 return text; � 4 1 � 4 47 } 48 public static string dekripsistring C, int prima, int d{ 49 BigInteger[] p = new BigInteger[50000]; � 1 1 � 1 50 string text = ; � 1 1 � 1 51 string[] bitsplain = C.Split ; � 3 1 � 3 52 StringBuilder sb = new StringBuilder; � 1 1 � 1 53 for int i=0; ibitsplain.Length-1; i++{ � 7 � � 7 � 54 c[i] ← Convert.ToInt32bitsplain[i]; � 1 � � 1 � 55 BigInteger p = BigInteger. Powc[i],d prima � 1 � � 1 � 56 text += Convert.ToStringp+ ; � 6 � � 6 � 57 char asli = charc3x; � 1 � � 1 � 58 sb.Appendasli; � 8 � � 8 � 59 } 60 return text;} � 3 1 � 3 Universitas Sumatera Utara �� = � 1 + � 2 � + � 3 � + � 3 + � 1 + � 1 + � 4 + � 3 + � 3 + � 1 + � 4 + � 1 + � 2 � + � 6 � + � 1 � + � 5 + � 3 + � 3 + � 3 + � 1 + � 1 + � 1 + � 1 + � 5 � + � 6 � + � 1 + � 7 � + � 1 � + � 1 � + � 6 � + � 4 + � 1 + � 1 + � 3 + � 1 + � 7 � + � 1 � + � 1 � + � 1 � + � 8 � + � 3 = 14 � 1 + 7 � 3 + � 4 + 3 � 5 � + 5 � 1 + 2 � 2 + � 3 + 2 � 5 + 3 � 6 + 2 � 7 + � 8 � 1 = �� Kolom C pada tabel kode program merupakan variabel statement yang akan diproses dan kolom merupakan frekuensi komputasi statement. Kolom � � merupakan hasil perkalian dari C dan . Berdasarkan tabel 4.8 kompleksitas algoritma Massey- Omura adalah Big- � = ��. 4.4.2 Kompleksitas algoritma Even-Rodeh Kompleksitas algoritma Even-Rodeh dapat dilihat pada Tabel 4.9. Tabel 4.7. Kompleksitas Algoritma Even-Rodeh Kode Program � � � 1 public static string encode string kalimat{ 2 Listchar srtChar = sortedCharkalimat; � 1 1 � 1 3 int m = 0; � 1 1 � 1 4 string kode = ; � 1 1 � 1 5 string karasli = ; � 1 1 � 1 6 StringBuilder bitkom = new StringBuilder; � 1 1 � 1 7 Liststring kodeER = new Liststring; � 1 1 � 1 8 foreach char c in kalimat{ � 2 � � 2 � 9 bitkom.AppendCodesrtChar.IndexOfc; � 1 � � 1 � 10 } 11 m=0; � 1 1 � 1 12 while bitkom.Length 7 =0{ � 3 � � 3 � 13 bitkom.Append0; � 4 � � 4 � 14 m++; � 5 � � 5 � 15 } 16 if m=0{ � 6 1 � 6 17 string bitflag = Convert.ToStringm,2; � 1 1 � 1 18 while bitflag.Length 7 =0{ � 3 � � 3 � 19 bitflag = 0+bitflag; � 1 � � 1 � 20 } 21 bitkom.Appendbitflag; � 4 1 � 4 22 } 23 else 24 bitkom.Append0000000; � 4 1 � 4 25 string sbitkom = Convert.ToStringbitkom; � 1 1 � 1 26 StringBuilder charkom = new StringBuilder; � 1 1 � 1 27 int awal = 0; � 1 1 � 1 Universitas Sumatera Utara 28 for int i=7; isbitkom.Length+7; i+=7{ � 7 � � 7 � 29 int dec = Convert. ToInt32sbitkom.Substringawal,7, 2; � 1 � � 1 � 30 char chr = chardec; � 1 � � 1 � 31 charkom.Appendchr; � 1 � � 1 � 32 awal = i; � 1 � � 1 � 33 } 34 charkom.Append; � 1 1 � 1 35 for int j=0; jsrtChar.Count; j++{ � 2 � � 2 � 36 charkom.AppendsrtChar[j]; � 1 � � 1 � 37 } 38 return charkom.ToString; � 8 1 � 8 39 } 40 public static string decodestring charkompresi{ 41 StringBuilder binn = new StringBuilder; � 1 1 � 1 42 string karakter = strkom. Splitnew [] {}, StringSplitOptions.N one[0]; � 1 1 � 1 43 foreach char c in charkompresi{ � 2 � � 2 � 44 string t = Convert. ToStringSystem.Convert.ToInt32c,2; � 1 � � 1 � 45 if t.Length = 7{ � 6 � � 6 � 46 for int i=0; i7-t.Length; i++{ � 7 � 2 � 7 n 2 47 binn.Append0; � 4 � 2 � 4 n 2 48 } 49 binn.Appendt; � 4 � � 4 � 50 } 51 else 52 binn.Appendt; � 4 � � 4 � 53 } 54 string bin = binn.ToString; � 1 1 � 1 55 int bitf = Convert. ToInt32bin.Substringbin.Length-7,2; � 1 1 � 1 56 ifbitf == 0 � 6 1 � 6 57 bin = bin.Substring0,bin.Length-7; � 1 1 � 1 58 else 59 bin = bin.Substring0,bin.Length-7+bitf � 1 1 � 1 60 for int y=0; ykarakter.Length; y++{ � 7 � � 7 � 61 kodeER. AddCodey � 4 � � 4 � 62 } 63 for int y=0; ykarakter.Count; y++{ � 7 � � 7 � 64 kodeER.AddCodey; 65 } 66 foreach char c in bin{ � 2 � � 2 � 67 kode += c; � 4 � � 4 � 68 if kodeER.Containskode � 6 � � 6 � 69 karasli += karakter[kodeER.IndexOfkode]; � 5 � � 5 � 70 kode= ; � 1 � � 1 � 71 } 72 } 73 return karasli.ToString; � 8 1 � 8 74 } 75 public static string Codeint n{ 76 StringBuilder kode = new StringBuilder; � 1 1 � 1 Universitas Sumatera Utara 77 if n4{ � 6 1 � 6 78 string s = Convert.ToStringn,2; � 1 1 � 1 79 for int i = 0; i3-s.Length; i++{ � 7 � � 7 � 80 kode.Append0; � 4 � � 4 � 81 } 82 kode.Appends; � 4 1 � 4 83 } 84 else { 85 kode.Append0; � 4 1 � 4 86 while n=4{ � 3 � � 3 � 87 string st = Convert.ToStringn,2; � 1 � � 1 � 88 kode.Insert0,st; � 4 � � 4 � 89 n = st.Length; � 1 � � 1 � 90 } 91 } 92 return kode.ToString; � 8 1 � 8 93 } �� = � 1 + � 1 + � 1 + � 1 + � 1 + � 1 + � 1 + � 2 � + � 1 � + � 1 + � 3 � + � 4 � + � 5 � + � 6 + � 1 + � 3 � + � 1 � + � 4 + � 4 + � 1 + � 1 + � 1 + � 7 � + � 1 � + � 1 � + � 1 � + � 1 � + � 8 + � 1 + � 2 � + � 1 � + � 6 � + � 7 n 2 + � 4 n 2 + � 4 � + � 4 � + � 1 + � 1 + � 6 + � 1 + � 1 + � 7 � + � 4 � + � 7 � + � 2 � + � 4 � + � 6 � + � 5 � + � 1 � + � 8 + � 1 + � 6 + � 1 + � 1 + � 1 � + � 2 + � 7 � + � 4 � + � 4 + � 4 + � 3 � + � 1 � + � 4 � + � 1 � + � 8 = 20 + 4 � 4 + 3 � 6 + 3 � 8 � + 11 � 1 + 4 � 2 + 3 � 3 + 7 � 4 + 2 � 5 + 2 � 6 + 4 �7n1+�4+�7n2 = �� 2 Hasil dari kompleksitas algoritma Even-Rodeh berdasarkan Tabel 4.9 adalah Big- � = �� 2 . Universitas Sumatera Utara

BAB 5 KESIMPULAN DAN SARAN