131
Universitas Sumatera Utara
132
Universitas Sumatera Utara
133
Universitas Sumatera Utara
134
Universitas Sumatera Utara
135
Universitas Sumatera Utara
136
Universitas Sumatera Utara
137
Universitas Sumatera Utara
138
Universitas Sumatera Utara
139
Universitas Sumatera Utara
140
Universitas Sumatera Utara
141
Universitas Sumatera Utara
142
Universitas Sumatera Utara
143
Universitas Sumatera Utara
144
Universitas Sumatera Utara
145
Universitas Sumatera Utara
146
Universitas Sumatera Utara
147
Universitas Sumatera Utara
148
Universitas Sumatera Utara
149
Universitas Sumatera Utara
150
Universitas Sumatera Utara
151
Universitas Sumatera Utara
152
LISTING PROGRAM
1.
Module gate.py
import sys sys.path.append("C:\skrip") import pythonA def gerbang(fungsi): if(fungsi == "bangkitKunci"): from pythonA import bangkitkanKunci p, q, n = bangkitkanKunci() print(p, q, n) elif(fungsi == "cekKunci"): from pythonA import cekKunci hasil = cekKunci(b,c) print(hasil) elif(fungsi == "enkripsi"): from pythonA import programEnkripsi C = programEnkripsi(d, b) for i in range(len(C)): print(C[i], end = " ") elif(fungsi == "dek"): from pythonA import decryptCiphertext cetak = decryptCiphertext(d, b, c) for i in range(len(cetak)): print(cetak[i], end = " ") elif(fungsi == "dek2"): from pythonA import decryptCiphertext2 cetak = decryptCiphertext2(d, b, c) for i in range(len(cetak)): print(cetak[i], end = " ") elif(fungsi == "cari"): from pythonA import cariHitamDariPath hasil = cariHitamDariPath(d, b) for i in range(len(hasil)): print(hasil[i], end = '') if(i < len(hasil)-1): print(',', end = '') elif(fungsi == "embed"): from pythonA import jalankanSisip stroutput = jalankanSisip(d, e, b) print(stroutput) elif(fungsi == "ekstrak"): from pythonA import jalankanEkstrak stroutput = jalankanEkstrak(d) print(stroutput) global a a = str(sys.argv[1]) global b b = int(sys.argv[2]) global c c = int(sys.argv[3]) global d d = str(sys.argv[4]) global e
Universitas Sumatera Utara
153 e = str(sys.argv[5]) gerbang(a)
2.
Module pythonA.py
import sys, random, time, codecs from PIL import Image import numpy as np class Timer(object): ''' timer starts with class initialisation ''' def __init__(self): self.t1= time.time() self.t2= time.time() def getElapsedlTime(self): # gets total elapsed from class initialsation self.delta=time.time()-self.t1 return '{0:.3f}'.format(self.delta) def getTimeDifference(self): # gets time elapsed from previous reading (for first reading this is equal to total time elapsed getElapsedlTime() self.delta=time.time()-self.t2 self.t2 = time.time() return '{0:.3f}'.format(self.delta) def differentRandom(n): x = [] for i in range(0, len(str(n))): a = random.randint(2,n-1) while a in x: a = random.randint(2,n-1) x.append(a) return x def toBin(x): return "{0:b}".format(x) def ntobin(n): return toBin(n-1) def get_t(biner_n): t = 0 l_biner_n = int(len(biner_n))-1 for i in range(l_biner_n, -1, -1): if(biner_n[i] == "0"): t += 1 if(biner_n[i] == "1"): break return t def get_u(biner_n, t): bin_u = biner_n[0:int(len(biner_n))-t] u = int(bin_u, 2) return u
Universitas Sumatera Utara
154 def modExpSAM(x, y, z): b = toBin(y) t = len(b) result = 1 for i in range(0, t): result = (result * result) % z if(b[i] == "1"): result = (result * x) % z return result def witness(a,u,n,t): x = [] x.append(modExpSAM(a, u, n)) for i in range(1, t+1): x.append(modExpSAM(x[i-1],2,n)) if x[i] == 1 and x[i-1] != 1 and x[i-1] != n-1: return True if x[t] != 1: return True return False def MillerRabin(n): biner_n = ntobin(n) t = get_t(biner_n) u = get_u(biner_n, t) a = differentRandom(n) for i in range(len(a)): if witness(a[i],u,n,t): return False return True def isPrime(x): lowPrimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89, 97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,18 1,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277 ,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383, 389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,4 91,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,60 7,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719 ,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829, 839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,9 67,971,977,983,991,997] if x in lowPrimes: return True elif x & 1 != 0: return MillerRabin(x) return False def bangkitkanKunci(): syarat_tdk_terpenuhi = True while syarat_tdk_terpenuhi: p = random.randint(3,10000) if (p % 4 == 3) and isPrime(p): syarat_tdk_terpenuhi = False syarat_tdk_terpenuhi = True while syarat_tdk_terpenuhi: q = random.randint(3,10000) if (q != p) and (q % 4 == 3) and isPrime(q): syarat_tdk_terpenuhi = False n = p * q return p, q, n
Universitas Sumatera Utara
155
def cekKunci(key1, key2): if (key1 % 4 == 3) and isPrime(key1) and (key2 % 4 == 3) and isPrime(key2) and (key1 != key2): return "T" else: return "F" def enkripsi(P, n): if P < n: C = modExpSAM(P,2,n) return C return False def encryptAll(P, n): C = [] for i in range(0, len(P)): C.append(enkripsi(ord(P[i]),n)) if C[i] == False: break; return C def programEnkripsi(plaintext, kunciPublik): measure=Timer() P = str(plaintext) n = int(kunciPublik) C = encryptAll(P, n) C.append(measure.getElapsedlTime()) return C def extEuclid(a,b): A, B, x, lastx, y, lasty = a, b, 1, 0, 0, 1 while (B > 0): hasilBagi = A//B sisaBagi = A - hasilBagi * B A, B = B, sisaBagi S = x - hasilBagi * lastx x, lastx = lastx, S T = y - hasilBagi * lasty y, lasty = lasty, T return A, x, y def CRT(mp, mq, p, q): n = p * q M1 = n // p M2 = n // q gcd, y1, y2 = extEuclid(M1,M2) return mp*M1*y1, mq*M2*y2, n def autoDekripsi(C, p, q): mp = modExpSAM(C, (p+1)//4, p) mq = modExpSAM(C, (q+1)//4, q) x, y, n = CRT(mp,mq,p,q) P1 = (x + y) % n P2 = (x - y) % n P3 = (-x + y) % n P4 = (-x - y) % n
Universitas Sumatera Utara
156 return min(P1, P2, P3, P4) def convertListStringCToInt(C): hasil = [] c = C.split(',') for i in c: hasil.append(int(i)) return hasil def tulisHasilDekripsi(P): namaFile = "SUM - hasil dekripsi dari python berupa ASCII.txt" path = "C:\\Users\\hp\\Documents\\" + namaFile try: with codecs.open(path, "w", encoding = "utf-8") as file: file.write(P) file.close() return True except: return False def decryptCiphertext2(C, p, q): measure=Timer() C = convertListStringCToInt(C) P = [] for i in range(0, len(C)): minP = autoDekripsi(C[i], p , q) P.append(chr(minP)) stringP = ''.join(P) et = measure.getElapsedlTime() cetak = [] cetak.append(stringP) cetak.append(et) temp = tulisHasilDekripsi(stringP) return cetak def decryptCiphertext(C, p, q): measure=Timer() C = list(C) ordo = [] for i in range(len(C)): ordo.append(ord(C[i])) C = ordo P = [] for i in range(0, len(C)): minP = autoDekripsi(C[i], p , q) P.append(chr(minP)) stringP = ''.join(P) et = measure.getElapsedlTime() cetak = [] cetak.append(stringP) cetak.append(et) temp = tulisHasilDekripsi(stringP) return cetak def bacaImage(lokasiFile): try: listGambar = [] myimage = Image.open(lokasiFile).convert('RGB') pix = myimage.load() width = myimage.size[0]
Universitas Sumatera Utara
157 height = myimage.size[1] for i in range(width): for j in range(height): listGambar.append(pix[i,j]) ndarray = np.array(myimage) imgAsli = Image.fromarray(ndarray) return listGambar, width, height, imgAsli except: return False, False, False, False def sequentialSearch(pixels, toleransiWarnaMax): htm = 0 for i in range(0, len(pixels)): if(pixels[i][0] <= toleransiWarnaMax and pixels[i][1] <= toleransiWarnaMax and pixels[i][2] <= toleransiWarnaMax): htm += 1 return htm def cekRuangDanHitam(path, toleransi): listGambar, width, height, imgAsli = bacaImage(path) if(listGambar == False): return False, False if(toleransi < 15): toleransi = 15 elif(toleransi > 255): toleransi = 255 hitam = sequentialSearch(listGambar, toleransi) pr = listGambar[len(listGambar)-1][0] pg = listGambar[len(listGambar)-1][1] pb = listGambar[len(listGambar)-1][2] if(pr <= toleransi & pg <= toleransi & pb <= toleransi): hitam = hitam - 1 return (hitam * 3) // 4, hitam def cariHitamDariPath(path, toleransiWarnaMax): ruang, pjghitam = cekRuangDanHitam(path, toleransiWarnaMax) if(ruang and pjghitam == False): return False hasil = [] hasil.append(ruang) hasil.append(pjghitam) return hasil def fixingCiphertext(C): newC = [] for i in range(len(C)): strBiner = toBin(C[i]) if(len(strBiner) < 16): selisih = 16 - len(strBiner) newStrBiner = strBiner for x in range(selisih): newStrBiner = '0' + newStrBiner newC.append(newStrBiner) return newC def parsingCiphertext(listC): newC, result = [], [] for i in range(len(listC)): if(len(listC[i]) == 16): elemen = [] elemen.append(listC[i][:4])
Universitas Sumatera Utara
158 elemen.append(listC[i][4:8]) elemen.append(listC[i][8:12]) elemen.append(listC[i][12:]) newC.append(elemen) for i in range(len(newC)): for x in newC[i]: result.append(x) return result def returnToInt(C): newC = [] for i in range(len(C)): desimal = int(C[i],2) newC.append(desimal) return newC def splitIntCto4Int(C): ls = C.split(',') il = [] for i in ls: il.append(int(i)) lbil = fixingCiphertext(il) parse4lbil = parsingCiphertext(lbil) desimalparse = returnToInt(parse4lbil) return desimalparse def fixLengthBeforeEmbed(C): while(len(C) % 3 != 0): C.insert(len(C), 0) index, color = 0, [] for i in range(len(C)//3): color.append((C[index], C[index+1], C[index+2])) index += 3 return color def filterGambar(listGambar): temp = [] for elemen in listGambar: if(elemen == (254, 254, 254)): elemen = (255, 255, 255) temp.append(elemen) return temp def pemetaanHitam(pixels, toleransiWarnaMax): htm = [] for i in range(0, len(pixels)-1): if(pixels[i][0] <= toleransiWarnaMax and pixels[i][1] <= toleransiWarnaMax and pixels[i][2] <= toleransiWarnaMax): htm.append(i) return htm def cekSyaratSebelumEmbed(listHitam, listWarnaC): if(len(listHitam) >= len(listWarnaC)): return True return False def transposeMatrix(M): return [ [ row[i] for row in M ] for i in range(len(M[0])) ] def sisip(arrayGambar, indexHitam, tinggi, warna):
Universitas Sumatera Utara
159 for i in range(len(warna)): arrayGambar[indexHitam[i]] = warna[i] if((len(warna)) < len(arrayGambar)): arrayGambar[indexHitam[len(warna)-1] + 1] = (254,254,254) stego = arrayGambar temp, stegoImg = [], [] for i in range(1, len(arrayGambar)+1): temp.append(arrayGambar[i-1]) if(i % tinggi == 0): stegoImg.append(temp) temp = [] stegoImg = transposeMatrix(stegoImg) stegoImg = np.array(stegoImg, "uint8") stegoImg = Image.fromarray(stegoImg) return stego, stegoImg def simpan(stegoImg): return stegoImg.save("C:/Users/hp/Documents/stegoimgpy.bmp", "BMP") def getRGB(cariCipher): r, g, b = [], [], [] for color in cariCipher: r.append(color[0]) g.append(color[1]) b.append(color[2]) return r, g, b def printRGBinStringAndReturnString(r,g,b): temp = "" for i in range(len(r)): temp += str(r[i]) if(i != len(r)-1): temp += "," temp += "/" for i in range(len(g)): temp += str(g[i]) if(i != len(g)-1): temp += "," temp += "/" for i in range(len(b)): temp += str(b[i]) if(i != len(b)-1): temp += "," return temp def jalankanSisip(intCiphertext, filename, toleransiWarnaMax): measure=Timer() intCiphertext = list(intCiphertext) ordo = [] for i in range(len(intCiphertext)): ordo.append(ord(intCiphertext[i])) temp = "" for i in range(len(ordo)): temp += str(ordo[i]) if(i != len(ordo)-1): temp += "," intCiphertext = temp
Universitas Sumatera Utara
160 listCi = splitIntCto4Int(intCiphertext) listWarna = fixLengthBeforeEmbed(listCi) listGambar, lebar, tinggi, imgAsli = bacaImage(filename) listGambarFilter = filterGambar(listGambar) hitam = pemetaanHitam(listGambarFilter, toleransiWarnaMax) syaratEmbed = cekSyaratSebelumEmbed(hitam, listWarna) if(syaratEmbed): stegoArray, stegoImg = sisip(listGambarFilter, hitam, tinggi, listWarna) simpan(stegoImg) r, g, b = getRGB(stegoArray) stroutput = printRGBinStringAndReturnString(r,g,b) et = measure.getElapsedlTime() stroutput += " " + str(et) return stroutput et = measure.getElapsedlTime() stroutput = "False " + str(et) return stroutput def cariTitikPutih(listGambarEkstrak): putih = 0 for e in listGambarEkstrak: if((e[0] == 254) and (e[1] == 254) and (e[2] == 254)): putih += 1 if(putih != 1): return False elif((putih == 1) and (listGambarEkstrak[0] != (254, 254, 254))): return True return False def cariCiphertext(listGambar): listC = [] for e in listGambar: if((e[0] == 254) and (e[1] == 254) and (e[2] == 254)): break if((e[0] <= 15) and (e[1] <= 15) and (e[2] <= 15)): listC.append(e) return listC def convertColorEkstrakToListInt(CE): il = [] for i in CE: for e in i: il.append(int(e)) return il def removeLastZeroOutofRange(liCE): if(len(liCE) % 4 != 0): for i in range(len(liCE) % 4): idxAkhir = len(liCE) - 1 liCE.pop(idxAkhir) return liCE def ambilEmpat(L): i = 0 hasil = []
Universitas Sumatera Utara
161 for iterasi in range(len(L) // 4): hasil.append((L[i], L[i+1], L[i+2], L[i+3])) i += 4 return hasil def dariEmpatJadiBiner(L): hasil, binerfix = [], [] for e in L: for i in e: biner = toBin(i) while(len(biner) < 4): biner = '0' + biner binerfix.append(biner) idx = 0 for i in range(len(binerfix) // 4): hasil.append(binerfix[idx] + binerfix[idx+1] + binerfix[idx+2] + binerfix[idx+3]) idx += 4 return hasil def biner16keInt(L): hasil = [] for e in L: hasil.append(int(e, 2)) return hasil def cetakstringint(L): hasil = "" for i in range(len(L)): hasil += str(L[i]) if( i != len(L)-1): hasil += "," return hasil class Convert: def toLI(self, string): temp = string.split(',') temp2 = [] for e in temp: temp2.append(int(e)) return temp2 def toSI(self, L): temp = "" for i in range(len(L)): temp += str(L[i]) if(i < len(L)-1): temp += ',' return temp def toDec(self, P): temp = [] for i in range(len(P)): temp.append(ord(P[i])) return temp def toASCII(self, string): string = self.toLI(string) temp = ""
Universitas Sumatera Utara
162 for e in string: temp += chr(e) return temp def tulisHasilEkstrakASCII(C): gagal = False try: C = Convert().toLI(C) temp = [] for e in C: try: temp.append(chr(e)) except: gagal = True continue C = temp temp = "" for i in range(len(C)): temp += str(C[i]) C = temp except: C = C namaFile = "SUM - hasil dekripsi dari python berupa ASCII.txt" path = "C:\\Users\\hp\\Documents\\" + namaFile try: with codecs.open(path, "w", encoding = "utf-8") as file: file.write(C) file.close() return True except: return False def jalankanEkstrak(path): measure=Timer() listGambarEkstrak, width, height, imgAsli= bacaImage(path) if(cariTitikPutih(listGambarEkstrak)): cariCipher = cariCiphertext(listGambarEkstrak) liCE = convertColorEkstrakToListInt(cariCipher) liCE = removeLastZeroOutofRange(liCE) liCE = ambilEmpat(liCE) liCE = dariEmpatJadiBiner(liCE) liCE = biner16keInt(liCE) stroutput = cetakstringint(liCE) temp = tulisHasilEkstrakASCII(stroutput) et = measure.getElapsedlTime() stroutput += "/" + str(et) return stroutput et = measure.getElapsedlTime() stroutput = "False/" + str(et) return stroutput
3.
Fungsi Pembangkit Kunci pada FormPembangkitKunci.cs
public void runPythonBangkitKunci(){ ProcessStartInfo p = new ProcessStartInfo(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false;
Universitas Sumatera Utara
163 p.Arguments = "c:\\skrip\\gate.py "+ "bangkitKunci 0 0 'x' 'x'"; // start the python program with two parameters try{ using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string []r = output.Split(new char[]{' '}); textBoxKunciP.Text = r[0].ToString(); textBoxKunciQ.Text = r[1].ToString(); textBoxKunciN.Text = r[2].ToString(); } } catch{ MessageBox.Show("Gagal melakukan pembangkit kunci.", "Kesalahan Proses Pembangkit Kunci", MessageBoxButtons.OK, MessageBoxIcon.Error); } } void ButtonGenerateClick(object sender, EventArgs e) { if(!string.IsNullOrWhiteSpace(textBoxKunciP.Text) & !string.IsNullOrWhiteSpace(textBoxKunciQ.Text)){ if(MessageBox.Show("Kunci yang anda tulis sebelumnya akan terhapus. Yakin untuk melanjutkan?", "Peringatan: Pembangkitan Kunci", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK){ runPythonBangkitKunci(); } } else{ runPythonBangkitKunci(); } }
4.
Fungsi Cek Kunci pada FormPembangkitKunci.cs
void ButtonCekKunciClick(object sender, EventArgs e){ if(string.IsNullOrWhiteSpace(textBoxKunciP.Text) | string.IsNullOrWhiteSpace(textBoxKunciQ.Text)){ MessageBox.Show("Pasangan kunci tidak boleh ada yang kosong.", "Kesalahan Kunci", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxKunciN.Text = ""; } else if(!string.IsNullOrWhiteSpace(textBoxKunciP.Text) & !string.IsNullOrWhiteSpace(textBoxKunciQ.Text)){ string hasil = runPythonCekKunci(); if(String.Equals(hasil, "T")){ int a = int.Parse(textBoxKunciP.Text); int b = int.Parse(textBoxKunciQ.Text); int c = a*b; textBoxKunciN.Text = c.ToString(); } else{ MessageBox.Show("Kunci tidak memenuhi syarat.", "Kesalahan Kunci", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxKunciN.Text = ""; } }
Universitas Sumatera Utara
164 } public string runPythonCekKunci(){ string hasil; int kunci1 = int.Parse(textBoxKunciP.Text); int kunci2 = int.Parse(textBoxKunciQ.Text); ProcessStartInfo p = new ProcessStartInfo(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false; p.Arguments = "c:\\skrip\\gate.py "+ "cekKunci " + kunci1 + " " + kunci2 + " 'x' 'x'"; try{ using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string []r = output.Split(new char[]{' '}); hasil = r[0][0].ToString(); } } catch{ MessageBox.Show("Gagal dalam melakukan cek kunci.", "Kesalahan Cek Kunci", MessageBoxButtons.OK, MessageBoxIcon.Error); hasil = ""; } return hasil; }
5.
Fungsi Enkripsi pada FormEnkripEmbed.cs
void ButtonEnkripsiClick(object sender, EventArgs e){ if(string.IsNullOrWhiteSpace(textBoxKunciPublik.Text)){ MessageBox.Show("Kunci publik belum ada.", "Kesalahan Enkripsi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if(string.IsNullOrEmpty(textBoxPesan.Text)){ MessageBox.Show("Tidak ada pesan (plaintext) yang terdeteksi.", "Kesalahan Enkripsi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else{ string cipherText = runPythonEnkripsi(); } } public string runPythonEnkripsi(){ string hasil; string hasil2; int n = int.Parse(textBoxKunciPublik.Text); string plaintext = textBoxPesan.Text.ToString(); int pjgPlaintext = textBoxPesan.Text.Length; string pltxt1 = plaintext.Replace("\"","\\\""); int temporary = 0; ProcessStartInfo p = new ProcessStartInfo(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false; p.Arguments = "c:\\skrip\\gate.py "+ "enkripsi " + n + " " + temporary + " \"" + pltxt1 + "\" 'x'"; try{
Universitas Sumatera Utara
165 using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string r = output; hasil = r.ToString(); hasil2 = hasil.Replace(" ",","); hasil2 = hasil2.Remove(hasil2.Length-1,1); string elapsedTime = hasil2.Split(',').Last(); textBoxWaktuProses.Text = elapsedTime; hasil2 = hasil2.Remove((hasil2.Length elapsedTime.Length), elapsedTime.Length); hasil2 = hasil2.Remove(hasil2.Length-1,1); if(hasil2 == "False"){ MessageBox.Show("Kunci publik tidak memenuhi syarat.", "Kesalahan Melakukan Enkripsi", MessageBoxButtons.OK, MessageBoxIcon.Error); hasil2 = ""; } else{ textBoxCiphertext.Text = hasil2.ToString(); try{ string kode = textBoxCiphertext.Text.ToString(); List<string> listHasilSplit = new List<string>(kode.Split(',')); List
ci = listHasilSplit.ConvertAll(x => Convert.ToInt32(x)); List liChar = new List(ci.ConvertAll(x => Convert.ToChar(x))); string charToString = string.Join("", liChar.ToArray()); kode = charToString; textBoxCipherASCII.Text = kode.ToString(); } catch{ textBoxCipherASCII.Text = hasil2.ToString(); } MessageBox.Show("Berhasil melakukan enkripsi (" + elapsedTime + " detik)", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch{ MessageBox.Show("Kesalahan melakukan enkripsi", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error); hasil2 = ""; } return hasil2; }
6.
Fungsi Cari Titik Hitam pada FormEnkripEmbed.cs
void ButtonCariClick(object sender, EventArgs e){ if(string.IsNullOrEmpty(textBoxPathBrowseImage.Text)){ MessageBox.Show("Gambar belum dipilih.", "Kesalahan Membaca Titik Hitam", MessageBoxButtons.OK, MessageBoxIcon.Error); }
Universitas Sumatera Utara
166 else{ string path = textBoxPathBrowseImage.Text.ToString(); if(string.IsNullOrEmpty(textBoxToleransiMax.Text)){ MessageBox.Show("Batas toleransi maksimum dari nilai warna hitam belum ditentukan.", "Kesalahan Membaca Titik Hitam", MessageBoxButtons.OK, MessageBoxIcon.Error); } else{ int toleransi = int.Parse(textBoxToleransiMax.Text); if((toleransi < 15) || (toleransi > 255)){ MessageBox.Show("Toleransi melebihi nilai maksimum.\nNilai harus diantara 15 sampai 255", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxToleransiMax.Text = ""; textBoxToleransiMax.SelectAll(); } else{runPythonCekHitamFromPath(path, toleransi);} } } } void runPythonCekHitamFromPath(string path, int toleransi){ string hasil; int temporary = 0; ProcessStartInfo p = new ProcessStartInfo(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false; p.Arguments = "c:\\skrip\\gate.py "+ "cari " + toleransi + " " + temporary + " \"" + path + "\" 'x'"; try{ using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string r = output; hasil = r.ToString(); string[] parts = hasil.Split(','); string hitam = parts[1]; string ruang = parts[0]; textBoxJumlahTitikHitam.Text = hitam; MessageBox.Show("Jumlah karakter dari pesan rahasia yang dapat disisip sebanyak " + ruang + " karakter", "Informasi Jumlah Karakter", MessageBoxButtons.OK, MessageBoxIcon.Information); try{ int pjgc = 0; try{ string C = textBoxCiphertext.Text.ToString(); List<string> listHasilSplit = new List<string>(C.Split(',')); List ci = listHasilSplit.ConvertAll(x => Convert.ToInt32(x)); List liChar = new List(ci.ConvertAll(x => Convert.ToChar(x))); string charToString = string.Join("", liChar.ToArray()); pjgc = charToString.Length; } catch{pjgc = textBoxCiphertext.Text.Length;}
Universitas Sumatera Utara
167 finally{ int pjgruanghtm = int.Parse(ruang); if(pjgruanghtm < pjgc){ MessageBox.Show("Penyisipan tidak dapat dilakukan.\nJumlah karakter pesan rahasia melebihi jumlah yang dapat disisip.", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } } catch{ //none } } } catch{ MessageBox.Show("Kesalahan dalam mencari titik hitam.", "Kesalahan Pencarian Titik Hitam", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
7.
Fungsi Embed pada FormEnkripEmbed.cs
void ButtonEmbedClick(object sender, EventArgs e){ if(!string.IsNullOrEmpty(textBoxCiphertext.Text)){ string result = textBoxCiphertext.Text.ToString(); try{ List<string> listHasilSplit = new List<string>(result.Split(',')); List ci = listHasilSplit.ConvertAll(x => Convert.ToInt32(x)); List liChar = new List(ci.ConvertAll(x => Convert.ToChar(x))); string charToString = string.Join("", liChar.ToArray()); result = charToString; } catch{//None} if(string.IsNullOrEmpty(textBoxPathBrowseImage.Text)){ MessageBox.Show("Cover Image belum dipilih.", "Kesalahan Penyisipan (Embed)", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if(string.IsNullOrEmpty(textBoxToleransiMax.Text)){ MessageBox.Show("Batas toleransi maksimum dari nilai warna hitam belum ditentukan.", "Kesalahan Penyisipan (Embed)", MessageBoxButtons.OK, MessageBoxIcon.Error); } else{ string path = textBoxPathBrowseImage.Text.ToString(); string cipher = result; int maxTolerance = int.Parse(textBoxToleransiMax.Text.ToString()); if((maxTolerance < 15) || (maxTolerance > 255)){ MessageBox.Show("Toleransi melebihi nilai maksimum.\nNilai harus diantara 15 sampai 255", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxToleransiMax.Text = "";
Universitas Sumatera Utara
168 textBoxToleransiMax.SelectAll(); } else{runPyEmbed(cipher, path, maxTolerance);} } } else{MessageBox.Show("Tidak ada ciphertext yang terdeteksi.", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);} } void runPyEmbed(string cipher, string path, int maxTolerance){ string hasil; int temporary = 0; string jikapltxt = cipher.Replace("\"","\\\""); cipher = jikapltxt; ProcessStartInfo p = new ProcessStartInfo(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false; p.Arguments = "c:\\skrip\\gate.py "+ "embed " + maxTolerance + " " + temporary + " \"" + cipher + "\"" + " \"" + path + "\""; try{ using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string r = output; hasil = r.ToString(); List<string> listHasilSplit = new List<string>(hasil.Split(' ')); if(listHasilSplit[0] == "False"){ MessageBox.Show("Jumlah titik hitam tidak cukup untuk menyembunyikan warna ciphertext.", "Kesalahan: Penyisipan Tidak Dapat Dilakukan", MessageBoxButtons.OK, MessageBoxIcon.Error); } else{ textBoxWaktuProsesStegano.Text = listHasilSplit[1]; List<string> listSplit = new List<string>(listHasilSplit[0].Split('/')); List<string> tempR = new List<string>(listSplit[0].Split(',')); List<string> tempG = new List<string>(listSplit[1].Split(',')); List<string> tempB = new List<string>(listSplit[2].Split(',')); List R = tempR.ConvertAll(x => int.Parse(x)); List G = tempG.ConvertAll(x => int.Parse(x)); List B = tempB.ConvertAll(x => int.Parse(x)); int w = int.Parse(textBoxWCoverImage.Text.ToString()); int h = int.Parse(textBoxHCoverImage.Text.ToString()); int dim = w * h; Bitmap bmp = new Bitmap(w, h); int idx = 0; for(int i = 0; i < w; i++){ for(int j = 0; j < h; j++){
Universitas Sumatera Utara
169
bmp.SetPixel(i,j,Color.FromArgb(255, R[idx], G[idx], B[idx])); idx++; } } pictureBoxStegoImage.Image = bmp; } } } catch{MessageBox.Show("Kesalahan melakukan penyisipan.\nCoba tutup aplikasi dan lakukan kembali.", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);} }
8.
Fungsi Ekstrak pada FormEkstrakDekrip.cs
void ButtonEkstrakClick(object sender, EventArgs e){ if(pictureBoxStegoImage.Image != null){ string path = textBoxPathStegoImage.Text.ToString(); runPyEkstrak(path); } else{MessageBox.Show("Stego-image belum dipilih.", "Kesalahan Ekstrak Gambar", MessageBoxButtons.OK, MessageBoxIcon.Error);} } void runPyEkstrak(string path){ string hasil; string hasil2; ProcessStartInfo p = new ProcessStartInfo(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false; p.Arguments = "c:\\skrip\\gate.py "+ "ekstrak 15 0 \"" + path + "\"" + " x"; try{ using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string r = output; hasil = r.ToString(); List<string> listHasilSplit = new List<string>(hasil.Split('/')); textBoxWaktuProsesEkstrak.Text = listHasilSplit[1]; hasil2 = listHasilSplit[0]; if(hasil2 == "False"){ MessageBox.Show("Tidak ada pesan rahasia di dalam gambar.", "Hasil Ekstrak Tidak Ada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBoxCiphertext.Text = ""; } else{ textBoxCiphertext.Text = listHasilSplit[0]; string[] stringSeparators = new string[]{","}; string[] result; result = listHasilSplit[0].Split(stringSeparators, StringSplitOptions.None); char[] buffer = new char[result.Length]; Int32 temp; for(int i = 0; i < result.Length; i++){
Universitas Sumatera Utara
170 temp = Convert.ToInt32(result[i]); buffer[i] = Convert.ToChar(temp); } string charToString = new string(buffer); textBoxPesanAsli.Text = charToString; } } } catch{MessageBox.Show("Kesalahan melakukan ekstrak", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);} }
9.
Fungsi Dekripsi pada FormEkstrakDekrip.cs
void ButtonDekripsiClick(object sender, EventArgs e){ if(string.IsNullOrWhiteSpace(textBoxKunciP.Text) | string.IsNullOrWhiteSpace(textBoxKunciQ.Text)){ MessageBox.Show("Kunci private tidak boleh kosong.", "Kesalahan Dekripsi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if(string.IsNullOrEmpty(textBoxCiphertext.Text)){ MessageBox.Show("Tidak ada ciphertext terdeteksi.", "Kesalahan Dekripsi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else{ try{ string ciphertext = textBoxCiphertext.Text.ToString(); string[] bufferS = new string[textBoxCiphertext.Text.ToString().Length]; bufferS = ubahKeInt(); string result = ConvertStringArrayToStringJoin(bufferS); List<string> listHasilSplit = new List<string>(ciphertext.Split(',')); List ci = listHasilSplit.ConvertAll(x => Convert.ToInt32(x)); List liChar = new List(ci.ConvertAll(x => Convert.ToChar(x))); string charToString = string.Join("", liChar.ToArray()); ciphertext = charToString; string plaintext = runPythonDekripsi(ciphertext); } catch{ string ciphertext = textBoxCiphertext.Text.ToString(); string plaintext = runPythonDekripsi(ciphertext); } } } public string ConvertStringArrayToStringJoin(string[] array){ string result = string.Join(",", array); return result; } string[] ubahKeInt(){ string C = textBoxCiphertext.Text.ToString();
Universitas Sumatera Utara
171 char[] charArr = C.ToCharArray(); int val; string[] bufferS = new string[charArr.Length]; for(int i = 0; i < charArr.Length; i++){ val = Convert.ToInt32(charArr[i]); bufferS[i] = Convert.ToString(val); } return bufferS; } public string runPythonDekripsi(string strIntC){ string hasil; string hasil2; int kunciP = int.Parse(textBoxKunciP.Text); int kunciQ = int.Parse(textBoxKunciQ.Text); ProcessStartInfo p = new ProcessStartInfo(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false; p.Arguments = "c:\\skrip\\gate.py "+ "dek " + kunciP + " " + kunciQ + " " + "\"" + strIntC + "\" 'x'"; try{ using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string r = output; hasil = r.ToString(); string[] parts = hasil.Split(' '); string elapsedTime = parts[parts.Length - 2]; textBoxWaktuProsesDekripsi.Text = elapsedTime; hasil2 = hasil.Remove((hasil.Length elapsedTime.Length), elapsedTime.Length); hasil2 = hasil2.Remove(hasil2.Length-1,1); hasil2 = hasil2.Remove(hasil2.Length-1,1); textBoxPesanAsli.Text = hasil2; int pjgPesanAsli = hasil2.Length; textBoxPjgPesanAsli.Text = pjgPesanAsli.ToString(); MessageBox.Show("Berhasil melakukan dekripsi (" + elapsedTime + " detik)", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch{ strIntC = textBoxCiphertext.Text.ToString(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false; p.Arguments = "c:\\skrip\\gate.py "+ "dek2 " + kunciP + " " + kunciQ + " " + "\"" + strIntC + "\" 'x'"; try{ using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string r = output; hasil = r.ToString(); string[] parts = hasil.Split(' '); string elapsedTime = parts[parts.Length - 2]; textBoxWaktuProsesDekripsi.Text = elapsedTime;
Universitas Sumatera Utara
172 hasil2 = hasil.Remove((hasil.Length elapsedTime.Length), elapsedTime.Length); hasil2 = hasil2.Remove(hasil2.Length-1,1); hasil2 = hasil2.Remove(hasil2.Length-1,1); textBoxPesanAsli.Text = hasil2; int pjgPesanAsli = hasil2.Length; textBoxPjgPesanAsli.Text = pjgPesanAsli.ToString(); MessageBox.Show("Berhasil melakukan dekripsi (" + elapsedTime + " detik)", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch{ strIntC = textBoxPesanAsli.Text.ToString(); p.FileName = "c:\\Python33\\python.exe"; p.RedirectStandardOutput = true; p.UseShellExecute = false; p.Arguments = "c:\\skrip\\gate.py "+ "dek2 " + kunciP + " " + kunciQ + " " + "\"" + strIntC + "\" 'x'"; try{ using(Process exeProc = Process.Start(p)){ StreamReader s = exeProc.StandardOutput; String output = s.ReadToEnd(); string r = output; hasil = r.ToString(); string[] parts = hasil.Split(' '); string elapsedTime = parts[parts.Length - 2]; textBoxWaktuProsesDekripsi.Text = elapsedTime; hasil2 = hasil.Remove((hasil.Length elapsedTime.Length), elapsedTime.Length); hasil2 = hasil2.Remove(hasil2.Length1,1); hasil2 = hasil2.Remove(hasil2.Length1,1); textBoxPesanAsli.Text = hasil2; int pjgPesanAsli = hasil2.Length; textBoxPjgPesanAsli.Text = pjgPesanAsli.ToString(); MessageBox.Show("Berhasil melakukan dekripsi (" + elapsedTime + " detik)", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch{ MessageBox.Show("Kesalahan melakukan dekripsi.", "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error); hasil2 = ""; } } } return hasil2; }
Universitas Sumatera Utara
173
DAFTAR RIWAYAT HIDUP CURRICULUM VITAE
I.
II.
DATA PRIBADI / Personal Identification Nama Lengkap Tempat / Tgl. Lahir Jenis Kelamin Agama Kebangsaan Alamat
: : : : : :
Telepon Moto Hidup Tinggi / Berat Email
: : : :
Aulia Akbar Harahap Medan / 15 April 1993 Laki – laki Islam Indonesia Jalan Karya Pembangunan, Komplek BLPP No. 22 Gedung Johor, Medan, Sumatera Utara, Indonesia 20143 +62617865990 / +6283198507519 Berusaha dan Bersyukur 178 cm / 86 kg [email protected]
KESEHATAN / Health Tidak memiliki cacat fisik maupun mental dan tidak memiliki penyakit bawaan.
III.
KEMAMPUAN / Capabilities Bahasa Bahasa Pemrograman Database Lainnya
IV.
: Bahasa Indonesia, Bahasa Inggris : C#, Python, PHP, JavaScript, C++ : MySQL : HTML, CSS, Photoshop, Ms. Office, Adobe Flash
PENDIDIKAN FORMAL / Formal Education
[ 2010 – 2014 ] “Implementasi Sistem Keamanan Data Menggunakan Steganografi Teknik Pemetaan Titik Hitam dengan Pencarian Sekuensial dan Rabin Cryptosystem” S1 Ilmu Komputer, Fakultas Ilmu Komputer dan Teknologi Informasi Universitas Sumatera Utara
[ 2007 – 2010 ] SMA Negeri 2 Medan
[ 2005 – 2007 ] SMP Swasta Harapan Mandiri, Medan
[ 1998 – 2004 ] SD Angkasa I Lanud Medan
[ 1997 – 1998 ] TK Angkasa I Lanud Medan
Universitas Sumatera Utara
174
V.
PENDIDIKAN NON-FORMAL / Informal Education
[ 2005 – 2006 ] Ta’limul Qur’an Lil Aulad (TQA) Al- Amin, Medan
[ 2008 – 2010 ] Ganesha Operation, Medan.
VI.
PRESTASI / Achievements 1) Juara II Kompetisi Desain Grafis, ArTechno Festival 2011 Universitas Sumatera Utara [2011] 2) Peringkat II Tingkat TQAL, Perguruan Islam Al-Amin [2006]
VII.
PENGALAMAN KERJA / Working Experience 1) Desainer Grafis dan Wakil Sekretaris di CV Dhuo Creative, Medan [2011 – 2012] 2) Asisten Laboratorium di Ilmu Komputer Laboratory Center Fasilkom-TI USU, Medan [20112012] 3) Kerja Lepas (freelancer) di Focus, Active and Network Coorporation (FAN), Medan [2013]
VIII. PENGALAMAN BERBICARA / Speaking Experience 1) Pemateri di Pelatihan Kesekretariatan, UKMI Al-Khuwarizmi Fasilkom-TI USU, Medan [2013] 2) Pemateri Desain Web di Penerimaan Mahasiswa Baru, IMILKOM, Medan [2013] 3) Pemateri Photo Manipulation di Pelatihan Spesifikasi Dunia Ilmu Komputer (IKLC Mengabdi), Ilmu Komputer Laboratory Center Fasilkom-TI USU, Medan-Perbaungan [2013] 4) Pemateri di Pelatihan Kesekretariatan dan Teknik Persidangan, UKMI Al-Khuwarizmi Fasilkom-TI USU dan IMILKOM, Medan [2013] 5) Tutor Pelatihan Blog di Academy Syiar Media, Departemen Komunikasi Dakwah UKMI AdDakwah USU, Medan [2012] 6) Tutor Pelatihan Blog di Ad-Dakwah Bloggership Camp, Departemen Komunikasi Dakwah UKMI Ad-Dakwah USU, Medan [2012] 7) Instruktur di Pesantren Kilat Ramadhan, BKM Al-Farabi SMAN 2 Medan [2011] IX.
PENGALAMAN PERTEMUAN DAN DELEGASI / Conference and Delegation Experience 1) Delegasi studi banding dari USU ke Fakulti Sains Komputer dan Teknologi Maklumat, Universiti Putera Malaysia [2011]
X.
PELATIHAN / Trainings & Workshop 1) Peserta Pelatihan Jurnalistik Metro TV on Campus, Universitas Sumatera Utara, Medan [2013] 2) Peserta Workshop Digital Paperless Publication: ALAMAGZ (Al-Khuwarizmi Magazine), UKMI Al-Khuwarizmi Fasilkom-TI USU, Medan [2011] 3) Peserta ESQ Basic Training, Training ESQ Inhouse Basic Mahasiswa Angkatan 002, The ESQ Way 165, Medan [2011] 4) Peserta Workshop Design Talent: Desain Poster, CV Dhuo Creative, Medan [2011] 5) Peserta Workshop Konfigurasi Access Point & Wireless Security, PT Telkom Indonesia, Tbk Regional I Sumatera, Medan [2011] 6) Peserta Training Pengurus, BKM Al-Khuwarizmi, Medan [2011] 7) Peserta Training Emotional Spiritual Management, UKMI Al-Falak FMIPA USU, Medan [2010] 8) Peserta Workshop Teknik Hacking, IMILKOM Fair 2010, Medan [2010] 9) Peserta Workshop Graphic Design: Unlimited, IMILKOM Fair 2010, Medan [2010] 10) Peserta Workshop Web Development, IMILKOM Fair 2010, Medan [2010] 11) Peserta Workshop “Get Closer with Graphic Design”, BKM Al-Khuwarizmi, Medan [2010]
Universitas Sumatera Utara
175
Peserta Training Islam Ceria dan Kreatif, BKM Al-Khuwarizmi, Medan [2010] Peserta Inagurasi, IMILKOM, Medan [2010] 14) Peserta Ramadhan Student Expo, Muslim Youth Club, Medan [2008] 15) Peserta Kemah Desember, PMR 001 SMAN 2 Medan [2007] 16) Peserta Pesantren Kilat Ramadhan, BKM Al-Farabi SMAN 2 Medan [2007] 12) 13)
XI.
SEMINAR / Seminars 1) Peserta Seminar Nasional: “Pencaplokan Budaya”, Kongres Nasional Ikatan Lembaga Penalaran dan Penelitian Mahasiswa Indonesia IV, Medan [2013] 2) Peserta Seminar Teknologi Informasi: “The Future Augmented Reality: Research and Implementation”, Universitas Sumatera Utara, Medan [2012] 3) Peserta Seminar Teknologi Informasi: “Android The New Trend in Modern Operating System”, Universitas Sumatera Utara, Medan [2010]
XII.
PENGALAMAN ORGANISASI / Organizational Experiences 1) Ketua Relawan TIK (Indonesian ICT Volunteers) Komisariat USU [2013 – 2014] 2) Anggota Biro Kesekretariatan IMILKOM [2013 – 2014] 3) Koordinator Divisi Administrasi dan Pengarsipan KPU Ilmu Komputer USU [2012 – 2013] 4) Sekretaris Umum di UKMI Al-Khuwarizmi Fasilkom-TI USU [2012 – 2013] 5) Anggota Pembinaan Anggota di BKM Al-Khuwarizmi USU [2011] 6) Anggota Majelis Perwakilan Kelas di SMAN 2 Medan [2008 – 2009] 7) Anggota PMR 001 WIRA A di SMAN 2 Medan [2006 – 2007] 8) Anggota BKM Al-Farabi SMAN 2 Medan [2007 – 2009]
XIII. PENGALAMAN KEPANITIAAN / Committee Experiences 1) Panitia Pelaksana pada Pelatihan Sistem Informasi Geografis di S1 Ilmu Komputer USU [2013] 2) Anggota Acara di ArTechno 2013 [2013] 3) Panitia Pelaksana pada Pelatihan Sistem Informasi Geografis di S1 Ilmu Komputer USU [2012] 4) Anggota Publikasi dan Dokumentasi di PORSENI IMILKOM [2012] 5) Anggota Acara di Penerimaan Mahasiswa Baru S1 Ilmu Komputer USU [2012] 6) Anggota Publikasi dan Dokumentasi di ArTechno 2012 [2012] 7) Panitia Penyuluhan Internet Sehat di Program Kreativitas Mahasiswa [2012] 8) Bendahara Umum di Bakti Sosial BKM Al-Khuwarizmi USU [2011] 9) Anggota Publikasi dan Dokumentasi di Ramadhan Expo 1432 H (Muslim Youth Club) [2011] 10) Ketua Panitia Seminar Teknologi Informasi The Development of Modern Operating System Technology: “Android The New Trend in Modern Operating System” [2011] XIV. LAINNYA / Others 1) Relawan pada Penyuluhan Pengenalan Internet Sehat (Pengabdian Masyarakat) [2012] 2) Penerima Beasiswa Peningkatan Prestasi Akademik di FMIPA USU [2011 – 2012] 3) Peserta Lomba pada “Problem Solving” IMILKOM Contest [2012] 4) Peserta Lomba Poster Ilmiah pada Pameran Ilmiah dan Kreatifitas Mahasiswa [2012] 5) Penerima Sertifikat Kepengurusan BKM Al-Farabi SMAN 2 Medan sebagai Anggota Bina Usaha Periode 2009 – 2010 6) Penerima Penghargaan sebagai Koordinator di Pesantren Kilat Ramadhan 1430 H [2009]
Universitas Sumatera Utara