A-1 LISTING PROGRAM. 1. Form1.cs. Universitas Sumatera Utara

Similar documents
LISTING PROGRAM. 1. Module SkripsiUmri.py. import sys, operator, codecs, time. class Timer(object): def init (self): self.t1= time.

LISTING PROGRAM. a = b; b = c; c = a + b; } fibs.reverse(); for (int i = 0; i < fibs.count; i++) { if (n >= fibs[i]) { n = n - fibs[i];

LAMPIRAN A : LISTING PROGRAM

LAMPIRAN A : LISTING PROGRAM

LAMPIRAN A LISTING PROGRAM

LISTING PROGRAM. private void filetoolstripmenuitem_click(object sender, EventArgs e) { this.hide(); Form2 fr = new Form2(); fr.

create database ABCD use ABCD create table bolumler ( bolumkodu int primary key, bolumadi varchar(20) )

CALCULATOR APPLICATION

LISTING PROGRAM. void KOMPRESIToolStripMenuItemClick(object sender, EventArgs e) { Kompresi k = new Kompresi(); k.show(); this.

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

For this example, we will set up a small program to display a picture menu for a fast food take-away shop.

LISTING PROGRAM. mainform.vb A-1. Universitas Sumatera Utara

LISTING PROGRAM. namespace vigenere_des { public partial class MainPage : PhoneApplicationPage { public MainPage() { InitializeComponent(); }

// Precondition: None // Postcondition: The address' name has been set to the // specified value set;

CSIS 1624 CLASS TEST 6

Listing Program. private void exittoolstripmenuitem_click(object sender, EventArgs e) { Application.Exit(); }

LISTING PROGRAM. // // TODO: Add constructor code after the InitializeComponent() call. //

Lecture 8 Building an MDI Application

Object oriented lab /second year / review/lecturer: yasmin maki

Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

Answer on Question# Programming, C#

You can call the project anything you like I will be calling this one project slide show.

Huw Talliss Data Structures and Variables. Variables

LISTING PROGRAM. // // TODO: Add constructor code after the InitializeComponent()

IBSDK Quick Start Tutorial for C# 2010

Create your own Meme Maker in C#

} } public void getir() { DataTable dt = vt.dtgetir("select* from stok order by stokadi");

Form Properties Window

Appendix A Programkod

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

Using Template Bookmarks for Automating Microsoft Word Reports

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

LISTING PROGRAM. void FilteringToolStripMenuItemClick(object sender, EventAr s e) { Filtering a = new Filtering(); this.hide(); a.

Start Visual Studio and create a new windows form application under C# programming language. Call this project YouTube Alarm Clock.

Sub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0.

Team project 2017 Dony Pratidana S. Hum Bima Agus Setyawan S. IIP

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

Visual Basic/C# Programming (330)

A-1 LAMPIRAN A LISTING PROGRAM. Kode Program Form Main: Universitas Sumatera Utara

Chapter 8 Advanced GUI Features

Eyes of the Dragon - XNA Part 37 Map Editor Revisited

LISTING PROGRAM. // // TODO: Add constructor code after the InitializeComponent()

C# winforms gridview

UNIT-3. Prepared by R.VINODINI 1

Start Visual Studio, create a new project called Helicopter Game and press OK

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

// Program 2 - Extra Credit // CIS // Spring // Due: 3/11/2015. // By: Andrew L. Wright. //Edited by : Ben Spalding

LISTING PROGRAM. % UIWAIT makes pertama wait for user response (see UIRESUME) % uiwait(handles.figure1);

Writing Your First Autodesk Revit Model Review Plug-In

APÉNDICE J. CÓDIGO DEL ARCHIVO FORM1.CS EN LENGUAJE C# Comprende:

string spath; string sedifile = "277_005010X228.X12"; string sseffile = "277_005010X228.SemRef.EVAL0.SEF";

// Specify SEF file to load. oschema = (edischema) oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

Click on the empty form and apply the following options to the properties Windows.

FDSc in ICT. Building a Program in C#

Brian Kiser November Vigilant C# 2.5. Commonwealth of Kentucky Frankfort, Kentucky

XNA 4.0 RPG Tutorials. Part 24. Level Editor Continued

// Specify SEF file to load. edischema oschema = oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

عنوان مقاله : خواندن و نوشتن محتوای فایل های Excel بدون استفاده ازAutomation Excel تهیه وتنظیم کننده : مرجع تخصصی برنامه نویسان

How to create a simple ASP.NET page to create/search data on baan using baan logic from the BOBS client sample.

IST311 Chapter13.NET Files (Part2)

RegEx - Numbers matching. Below is a sample code to find the existence of integers within a string.

Listing Progam. Universitas Sumatera Utara

RegEx-validate IP address. Defined below is the pattern for checking an IP address with value: String Pattern Explanation

Class Test 5. Create a simple paint program that conforms to the following requirements.

private void Form1_Load(object sender, EventArgs e) {

pojedinačnom elementu niza se pristupa imeniza[indeks] indeks od 0 do n-1

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

Chapter 6 Dialogs. Creating a Dialog Style Form

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

Overview. Building a Web-Enabled Decision Support System. Integrating DSS in Business Curriculum. Introduction to DatabaseSupport Systems

Quick Guide for the ServoWorks.NET API 2010/7/13

II. Programming Technologies

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

visual studio vs#d express windows desktop

C:\homeworks\PenAttention_v13_src\PenAttention_v13_src\PenAttention4\PenAttention\PenAttention.cs 1 using System; 2 using System.Diagnostics; 3 using

namespace csharp_gen277x214 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Computer measurement and control

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

In-Class Worksheet #4

2.3 Add GDS Google Map to Visual Studio Toolbox and create a simple map project

Risk Sharing Pool. File Transfer via Web Services Technical Guide

private void closetoolstripmenuitem_click(object sender, EventArgs e) { this.close(); }

Bachelor s Thesis: Building Web Application for Mahabad University Graduate Affairs Afsaneh Nezami Savojbolaghi

Class Test 4. Question 1. Use notepad to create a console application that displays a stick figure. See figure 1. Question 2

Developing for Mobile Devices Lab (Part 1 of 2)

LIGHT_P_TOGGLE, LIGHT_N_TOGGLE, BATTERY_TOGGLE, ALTERNATOR_TOGGLE, AVIONICS_TOGGLE, FLOAT_RETRACT, FLOAT_EXTEND }

LISTING PROGRAM. com.example.jessicatamara.myapplication4;

بسم هللا الرحمن الرحيم المحاضرة السابعة مستوى ثالث علوم حاسوب برمجة مرئية 2 )عملي ) جامعة الجزيرة محافظة اب الجمهورية اليمنية النافذة الرئيسية

LISTING PROGRAM. if nargout [varargout{1:nargout}] = gui_mainfcn(gui_state, varargin{:}); else gui_mainfcn(gui_state, varargin{:}); end

Your First Windows Form

LISTING PROGRAM. % Edit the above text to modify the response to help cover. % Last Modified by GUIDE v Jun :24:43

namespace spojneice { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private string sconnection = ConfigurationManager.ConnectionStrings["Development"].ConnectionString

Chapter 2. Ans. C (p. 55) 2. Which is not a control you can find in the Toolbox? A. Label B. PictureBox C. Properties Window D.

Conventions in this tutorial

Lampiran 2 MASTER TABEL

Representing Recursive Relationships Using REP++ TreeView

Visual Studio Windows Form Application #1 Basic Form Properties

private string sconnection = ConfigurationManager.ConnectionStrings["Development"].ConnectionString

Transcription:

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