A-1 LISTING PROGRAM 1. Form1.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using IronPython.Hosting; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; using System.IO; using System.Diagnostics; using System.Windows.Forms; using System.Drawing; namespace program public partial class Form1 : Form public string imgpath; public string paddedimgpath; public string cipherteks; DateTime awal; DateTime akhir; TimeSpan total; public Form1() InitializeComponent(); private void button1_click(object sender, EventArgs e) DateTime awal; DateTime akhir; TimeSpan total; int waktupenyisipan; awal = DateTime.Now; if (ekskey.text == "" ekskey.text == "12345678" ekskey.text == "enkripsi") MessageBox.Show("kunci tidak boleh kosong!", "Peringatan!", MessageBoxButtons.OK, MessageBoxIcon.Error); else Process p = new Process(); // create process (i.e., the python program p.startinfo.filename = "C:\\Python27\\python.exe"; p.startinfo.redirectstandardoutput = true; p.startinfo.useshellexecute = false; // make sure we can read the output from stdout p.startinfo.arguments = "internal_key.py " + ekskey.text; // start the python program with two parameters p.start(); // start the process (the python program) StreamReader s = p.standardoutput; String output = s.readtoend();
A-2 string[] r = output.split(new char[] ' ' ); // get the parameter string q = r[0]; //string[] words = q.split('.'); intkey.text = output; p.waitforexit(); akhir = DateTime.Now; total = akhir - awal; waktupenyisipan = Convert.ToInt32(total.TotalMilliseconds); MessageBox.Show("Waktu pembangkitan kunci adalah: " + waktupenyisipan + " ms."); private void button3_click(object sender, EventArgs e) DateTime awal; DateTime akhir; TimeSpan total; int waktupenyisipan; awal = DateTime.Now; Process p = new Process(); // create process (i.e., the python program p.startinfo.filename = "C:\\Python27\\python.exe"; p.startinfo.redirectstandardoutput = true; p.startinfo.useshellexecute = false; // make sure we can read the output from stdout p.startinfo.arguments = "enkripsi_pesan.py " + plaintext.text.replace(' ', '_') + " " + ekskey.text;// start the python program with two parameters p.start(); // start the process (the python program) StreamReader s = p.standardoutput; String output = s.readtoend(); string[] r = output.split(new char[] ' ' ); // get the parameter string q = r[0]; //string[] words = q.split('.'); ciphertext.text = output; cipherteks = output; p.waitforexit(); akhir = DateTime.Now; total = akhir - awal; waktupenyisipan = Convert.ToInt32(total.TotalMilliseconds); MessageBox.Show("Waktu enkripsi adalah: " + waktupenyisipan + " ms."); private void button2_click(object sender, EventArgs e) try plaintext.text=""; OpenFileDialog bukaplaintext = new OpenFileDialog(); bukaplaintext.initialdirectory = ""; bukaplaintext.filter = "File Text (*.txt) *.txt"; bukaplaintext.filterindex = 1; bukaplaintext.restoredirectory = true; if (DialogResult.OK == bukaplaintext.showdialog()) string baca_teks = "";
A-3 StreamReader objreader = new StreamReader(bukaPlainText.FileName); baca_teks = objreader.readline(); while (baca_teks!= null) plaintext.text += baca_teks; baca_teks = objreader.readline(); objreader.close(); catch (Exception ex) MessageBox.Show("Terjadi Kesalah pada \n- " + ex.tostring()); private void button5_click(object sender, EventArgs e) OpenFileDialog thedialog = new OpenFileDialog(); thedialog.title = "Open Image File"; thedialog.filter = "PNG(*.png) *.png"; thedialog.initialdirectory = @"D:\"; thedialog.showdialog(); if (thedialog.filename.tostring()!= "") Image image = Image.FromFile(theDialog.FileName.ToString()); picturebox1.sizemode = PictureBoxSizeMode.StretchImage; picturebox1.image = image; imgpath = thedialog.filename.tostring(); MessageBox.Show("Citra berhasil diimport!", "Informasi!", MessageBoxButtons.OK, MessageBoxIcon.Information); private void button14_click_1(object sender, EventArgs e) DateTime awal; DateTime akhir; TimeSpan total; int waktupenyisipan; awal = DateTime.Now; if (eksdek.text == "" eksdek.text == "12345678" eksdek.text == "enkripsi") MessageBox.Show("kunci tidak boleh kosong!", "Peringatan!", MessageBoxButtons.OK, MessageBoxIcon.Error); else Process p = new Process(); // create process (i.e., the python program p.startinfo.filename = "C:\\Python27\\python.exe"; p.startinfo.redirectstandardoutput = true; p.startinfo.useshellexecute = false; // make sure we can read the output from stdout p.startinfo.arguments = "internal_key.py " + eksdek.text; // start the python program with two parameters p.start(); // start the process (the python program)
A-4 StreamReader s = p.standardoutput; String output = s.readtoend(); string[] r = output.split(new char[] ' ' ); // get the parameter string q = r[0]; //string[] words = q.split('.'); intdek.text= output; p.waitforexit(); p.waitforexit(); akhir = DateTime.Now; total = akhir - awal; waktupenyisipan = Convert.ToInt32(total.TotalMilliseconds); MessageBox.Show("Waktu pembangkitan kunci adalah: " + waktupenyisipan + " ms."); private void button12_click_1(object sender, EventArgs e) DateTime awal; DateTime akhir; TimeSpan total; int waktupenyisipan; awal = DateTime.Now; Process p = new Process(); // create process (i.e., the python program p.startinfo.filename = "C:\\Python27\\python.exe"; p.startinfo.redirectstandardoutput = true; p.startinfo.useshellexecute = false; // make sure we can read the output from stdout p.startinfo.arguments = "dekripsi_pesan.py " + imgpath + " " + eksdek.text;// start the python program with two parameters p.start(); // start the process (the python program) StreamReader s = p.standardoutput; String output = s.readtoend(); string[] r = output.split(new char[] ' ' ); // get the parameter string q = r[0]; //string[] words = q.split('.'); plaindek.text = output; p.close(); akhir = DateTime.Now; total = akhir - awal; waktupenyisipan = Convert.ToInt32(total.TotalMilliseconds); MessageBox.Show("Waktu dekripsi adalah: " + waktupenyisipan + " ms."); private void button6_click(object sender, EventArgs e) DateTime awal; DateTime akhir; TimeSpan total; int waktupenyisipan; awal = DateTime.Now; program Process p = new Process(); // create process (i.e., the python p.startinfo.filename = "C:\\Python27\\python.exe"; p.startinfo.redirectstandardoutput = true;
A-5 p.startinfo.useshellexecute = false; // make sure we can read the output from stdout p.startinfo.arguments = "imgpadding.py " + imgpath + " " + ekskey.text + " " + plaintext.text.replace(' ', '_');// start the python program with two parameters p.start(); // start the process (the python program) StreamReader s = p.standardoutput; String output = s.readtoend(); string[] r = output.split(new char[] ' ' ); // get the parameter string q = r[0]; string[] words = q.split('.'); paddedimgpath = words[0]; FileStream fs = new FileStream(words[0] + ".png", FileMode.Open); Image image = Image.FromStream(fs); picturebox2.sizemode = PictureBoxSizeMode.StretchImage; picturebox2.image = image; fs.close(); akhir = DateTime.Now; total = akhir - awal; waktupenyisipan = Convert.ToInt32(total.TotalMilliseconds); MessageBox.Show("Pesan Berhasil disisipkan!", "Informasi!", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Waktu penyisipan adalah: " + waktupenyisipan + " ms."); p.close(); private void button10_click(object sender, EventArgs e) OpenFileDialog thedialog = new OpenFileDialog(); thedialog.title = "Open Image File"; thedialog.filter = "PNG(*.png) *.png"; thedialog.initialdirectory = @"D:\"; thedialog.showdialog(); if (thedialog.filename.tostring()!= "") Image image = Image.FromFile(theDialog.FileName.ToString()); picturebox4.sizemode = PictureBoxSizeMode.StretchImage; picturebox4.image = image; imgpath = thedialog.filename.tostring(); MessageBox.Show("Citra berhasil diimport!", "Informasi!", MessageBoxButtons.OK, MessageBoxIcon.Information); private void button9_click(object sender, EventArgs e) DateTime awal; DateTime akhir; TimeSpan total; int waktupenyisipan; awal = DateTime.Now; Process p = new Process(); // create process (i.e., the python program p.startinfo.filename = "C:\\Python27\\python.exe"; p.startinfo.redirectstandardoutput = true; p.startinfo.useshellexecute = false; // make sure we can read the output from stdout
A-6 p.startinfo.arguments = "imgextractmsg.py " + imgpath;// start the python program with two parameters p.start(); // start the process (the python program) StreamReader s = p.standardoutput; String output = s.readtoend(); string[] r = output.split(new char[] ' ' ); // get the parameter string q = r[0]; string[] words = q.split('.'); chipdek.text = words[0]; akhir = DateTime.Now; total = akhir - awal; waktupenyisipan = Convert.ToInt32(total.TotalMilliseconds); MessageBox.Show("Pesan berhasil diekstrak!", "Informasi!", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Waktu ekstrsi adalah: " + waktupenyisipan + " ms."); p.close(); private void button1_click_1(object sender, EventArgs e) ekskey.text = ""; plaintext.text = ""; intkey.text = ""; ciphertext.text = ""; picturebox1.image = null; picturebox2.image = null; private void label7_click(object sender, EventArgs e) private void button2_click_1(object sender, EventArgs e) eksdek.text = ""; chipdek.text = ""; plaindek.text = ""; intdek.text = ""; picturebox4.image = null; 2. Function.py import binascii import Image def ascii_to_bit(message): return bin(int(binascii.hexlify(message), 16)).replace("b", "").rjust(8,'0') def bit_to_ascii(bit): ascii = ''; for i in range(0, len(bit), 8): n = int(bit[i:i+8], 2) ascii += binascii.unhexlify('%x' %n) return ascii
A-7 def divide_side(message_bit): i = 0 left = "" right = "" half_size = len(message_bit)/2; while (i < half_size): left = left + message_bit[i]; right = right + message_bit[i+half_size]; i+=1 return left,right def get_key_plus_bit(key_bit): pc_1 = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4] key_plus_bit = [] for i in range(0, len(pc_1)): key_plus_bit.append(key_bit[pc_1[i]-1]) return key_plus_bit def shift_bit(pre_bit, num_of_shift): for i in range(num_of_shift): temp_bit = pre_bit[0] pre_bit = pre_bit[1:] pre_bit += temp_bit return pre_bit def right_shift_bit(pre_bit, num_of_shift): for i in range(num_of_shift): temp_bit = pre_bit[27] pre_bit = pre_bit[:27] pre_bit = temp_bit + pre_bit return pre_bit def get_c1_to_c16(c, d): shift = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1] for i in range(16): c.append(shift_bit(c[i], shift[i])) d.append(shift_bit(d[i], shift[i])) return c, d def join(c, d): key_plus_block = [] for i in range(17): key_plus_block.append(c[i]+d[i]) return key_plus_block def get_key_plus_bit_2(cd_block): pc_2 = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32] key_plus_bit_2 = [] for i in range(1, len(cd_block)): cd_temp = "" for j in range (0, len(pc_2)): cd_temp += cd_block[i][pc_2[j]-1]; key_plus_bit_2.append(cd_temp) return key_plus_bit_2 def message_permutation_1(message):
A-8 ip = [58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7]; message_permutation_1 = "" for i in range(0, len(ip)): message_permutation_1 += message[ip[i]-1]; return message_permutation_1 def e_bit(message): e = [32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1]; e_bit = "" for i in range(0,len(e)): e_bit += message[e[i]-1]; return e_bit def xor_bit(e_rn,kn, x): result_bit = "" for i in range (0,len(e_rn)): result_bit += xor(e_rn[i], kn[x][i]) return result_bit def xor(bit1, bit2): if(bit1 == '1'): if(bit2=='1'): return'0' else: return'1' else: if(bit2=='1'): return '1' else: return'0' def b_n(k_xor): b_n = []; for i in range (0, len(k_xor), 6): temp = "" for j in range(i, i + 6): temp += k_xor[j] b_n.append(temp) return b_n def s_n(b_n, i, s): row = int(b_n[i][0]+b_n[i][5], 2) column = int(b_n[i][1]+b_n[i][2]+b_n[i][3]+b_n[i][4], 2) return bin(s[row][column]).replace("0b", "").zfill(4); def f(s_box): p = [16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25]; temp = "" for i in range(0, len(p)): temp+=(s_box[p[i]-1]) return temp def rn(ln_min1, f): temp = "" for i in range(0, len(f)):
A-9 temp += xor(ln_min1[i], f[i]) return temp def lnrn(kn, x, l, r): e = e_bit(r) m = xor_bit(e, kn, x) b = b_n(m) s1 = [[14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7],[0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8],[4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0],[ 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13]]; s2 = [[15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10],[ 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5],[0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15],[13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9]]; s3 = [[10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8],[13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1],[13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7], [1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12]]; s4 = [[7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15], [13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9], [10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4], [3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14]]; s5 = [[2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9], [14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 16], [4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14], [11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3]]; s6 = [[12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11], [10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8], [9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6], [4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13]]; s7 = [[4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1], [13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6], [1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2], [6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12]]; s8 =[[13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7], [1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2], [7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8], [2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11]]; s1b1 = s_n(b, 0, s1) s2b2 = s_n(b, 1, s2) s3b3 = s_n(b, 2, s3) s4b4 = s_n(b, 3, s4) s5b5 = s_n(b, 4, s5) s6b6 = s_n(b, 5, s6) s7b7 = s_n(b, 6, s7) s8b8 = s_n(b, 7, s8) s_box = s1b1 + s2b2 + s3b3 + s4b4 + s5b5 + s6b6 + s7b7 + s8b8 f_var = f(s_box) result = rn(l, f_var) return result def ip_min(rnln):
A-10 ip_inv = [40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25]; temp = []; for i in range(0, len(ip_inv)): temp.append(rnln[ip_inv[i]-1]); encrypt_m_bit = ''.join(temp) return encrypt_m_bit def get_img_res(imgpath, param): if(param == 'height'): param = 0 else: param = 1 img = Image.open(imgPath) imgsize = img.size return imgsize[param] def get_img_px(imgpath): img = Image.open(imgPath) imgpx = img.load() x = get_img_res(imgpath, 'height'); # x -> height y = get_img_res(imgpath, 'width'); # y -> width plainpx = [] for i in range (x): for j in range (y): plainpx.append(imgpx[i, j]) return plainpx # Get blue pixels from image for padding process def get_bluepx0(rgbapx): bluepx = [] for i in range (0, len(rgbapx)): bluepx.append(rgbapx[i][2]) return bluepx # Get blue pixels from image to get padded message def get_bluepx1(rgbapx): bluepx = [] for i in range (0, len(rgbapx)): if(rgbapx[i][3] == 0): # If alpha 0, that's the message limit break bluepx.append(rgbapx[i][2]) return bluepx def pad_bluepx(bluepx, msgbit): bluebit = [] for i in range(0, len(msgbit)): bluepxlist = list(bin(bluepx[i]).replace("0b", "")) bluepxlist[len(bluepxlist)-1] = msgbit[i] joinedbluepx = ''.join(bluepxlist) newbluepx = int(joinedbluepx, 2) bluebit.append(newbluepx) return bluebit def set_bluepx_in_plainpx(blue_pixel, plain_pixel): temp = [] for i in range(0, len(blue_pixel)): temp = list(plain_pixel[i]) temp[2] = blue_pixel[i]
A-11 plain_pixel[i] = temp return plain_pixel def extract_bluepx(bluepx): msgbit = '' for i in range(0, len(bluepx)): bluepxlist = list(bin(bluepx[i]).replace("0b", "")) msgbit += bluepxlist[len(bluepxlist)-1] return msgbit def create_png(imgpath, rgbapx, imgname, msglength): x = get_img_res(imgpath, 'height')# x -> height y = get_img_res(imgpath, 'width')# y -> width img = Image.new('RGBA', (x, y), 'white') k = 0 for i in range(x): for j in range(y): R = rgbapx[k][0] G = rgbapx[k][1] B = rgbapx[k][2] if( k == msglength ): A = 0 else: A = 255 img.putpixel((i, j), (R, G, B, A)) k += 1 return img.save(imgname, 'PNG') def get_key_bin(key): key_bin = ascii_to_bit(key) key_bin_pc1 = get_key_plus_bit(key_bin) key_bin_div = divide_side(key_bin_pc1) c0 = key_bin_div[0] d0 = key_bin_div[1] c = [c0] d = [d0] key_bin_c1_c16 = get_c1_to_c16(c, d) c0 = key_bin_c1_c16[0] d0 = key_bin_c1_c16[1] key_bin_join = join(c0,d0) key_bin_pc2 = get_key_plus_bit_2(key_bin_join) return key_bin_pc2 def encrypt_m(key_bin_pc2, message): message_bin = '' for i in range(0, 8): temp_bin = ascii_to_bit(message[i]) message_bin += temp_bin ip1 = message_permutation_1(message_bin) message_divide = divide_side(ip1) l0 = message_divide[0] r0 = message_divide[1] ln = l0 rn = r0 x = 0 while(x < 16): r_temp = rn
A-12 rn = lnrn(key_bin_pc2, x, ln, rn) ln = r_temp x += 1 rnln = str(rn) + str(ln) joined_c = "" c = ip_min(rnln) joined_c += c return joined_c def get_cipher_message(key_bin_pc2, message): padded_m = '' for i in range(0, len(message), 8): char_length = len(message[i:i+8]) if ( char_length < 8 ): padded_m += message[i:i+char_length].ljust(8,' ') else: padded_m += message[i:i+8].ljust(8,' ') message = padded_m join_e_m = '' for i in range(0, len(message), 8): join_e_m += encrypt_m(key_bin_pc2,message[i:i+8]) return join_e_m def decrypt_m(key_bin_pc2, message_bin): ip1 = message_permutation_1(message_bin) message_divide = divide_side(ip1) l0 = message_divide[0] r0 = message_divide[1] ln = l0 rn = r0 x = 15 while(x >- 1): r_temp = rn rn = lnrn(key_bin_pc2, x, ln, rn) ln = r_temp x -= 1 rnln = str(rn) + str(ln) joined_c = "" c = ip_min(rnln) joined_c += c return joined_c def get_plain_message(key_bin_pc2, message): join_e_m = '' for i in range(0, len(message), 64): join_e_m += decrypt_m(key_bin_pc2, message[i:i+64]) return join_e_m
A-13 3. Internal_key.py from function import * import sys #mengambil nilai dari argument ekskey.text key = sys.argv[1] key_bin_pc2 = get_key_bin(key) print str(key_bin_pc2) 4. Enkripsi_pesan.py from function import * import binascii import sys message = sys.argv[1].replace('_', ' '); key = sys.argv[2] key_bin_pc2 = get_key_bin(key) print get_cipher_message(key_bin_pc2, message) 5. ImgPadding.py from function import * import sys imgpath = sys.argv[1] key = sys.argv[2] message = sys.argv[3].replace('_', ' '); key_bin_pc2 = get_key_bin(key) joined_c = get_cipher_message(key_bin_pc2, message) msgbit = joined_c msglength = len(msgbit) plainpx = get_img_px(imgpath) bluepx = get_bluepx0(plainpx) paddedbluepx = pad_bluepx(bluepx, msgbit) paddedplainpx = set_bluepx_in_plainpx(paddedbluepx, plainpx) imgname = "D:\\PaddedImage.png" create_png(imgpath, paddedplainpx, imgname, msglength) print imgname
A-14 6. Dekripsi_pesan.py from function import * import binascii import sys key = sys.argv[2] imgpath = sys.argv[1] key_bin_pc2 = get_key_bin(key) plainpx = get_img_px(imgpath) bluepx = get_bluepx1(plainpx) message = extract_bluepx(bluepx) plain_bit = get_plain_message(key_bin_pc2, message) print bit_to_ascii(plain_bit) 7. ImgExtractMsg.py from function import * import sys imgpath = sys.argv[1] plainpx = get_img_px(imgpath) bluepx = get_bluepx1(plainpx) msgbit = extract_bluepx(bluepx) print str(msgbit)
B - 1 CURRICULUM VITAE -------------------------------------------------------------------------------------------------------- Data Pribadi Nama : Hengky Prayson Fangaro Gulo Tempat/Tanggal Lahir : Gunung Sitoli / 28 Agustus 1992 Tinggi/Berat Badan : 169 cm / 100 kg Agama : Kristen Protestan Kewarganegaraan : Indonesia Alamat : Jl. Jahe 6 no.2 Perumnas Simalingkar Medan Alamat Orang Tua : Jl. Jahe 6 no.2 Perumnas Simalingkar Medan Telp/ Hp : 085362402072 Email : hengkygulo@gmail.com -------------------------------------------------------------------------------------------------------- Riwayat Pendidikan [2010 2016] : S1 Ilmu Komputer, Medan [2007 2010] : SMK Negeri 9 Medan [2004 2007] : SMP Negeri 10 Medan [1999 2004] : SD Negeri Tohia Gunung Sitoli
B - 2 -------------------------------------------------------------------------------------------------------- Keahlian/Kursus Keahlian Komputer Bahasa : Pemrograman :Pyhton, C#, C++ English Database : MySQL Indonesia Perkantoran : Microsoft Office