A-1
LISTING PROGRAM
Kode Program Form Main.cs using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Linq; System.Text; System.Windows.Forms;
namespace EnkDekGUI { public partial class frmMain : Form { public frmMain() { InitializeComponent(); } private void enkripsiToolStripMenuItem_Click(object sender, EventArgs e) { frmEnkripsi enk = new frmEnkripsi(); enk.Show(); } private void dekripsiToolStripMenuItem_Click(object sender, EventArgs e) { frmDekripsi dek = new frmDekripsi(); dek.Show(); } private void tentangToolStripMenuItem_Click(object sender, EventArgs e) { frmTentang tentang = new frmTentang(); tentang.ShowDialog(); } private void enkripsiToolStripMenuItem1_Click(object sender, EventArgs e) { frmNihilistEnk nihilistenk = new frmNihilistEnk(); nihilistenk.Show(); } private void dekripsiToolStripMenuItem1_Click(object sender, EventArgs e) { frmNihilistDek nihilistdek = new frmNihilistDek(); nihilistdek.Show(); } } }
Universitas Sumatera Utara
A-2
Kode Program Form Nihilist Enkripsi.cs using using using using using using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; Microsoft.Office.Interop.Word; System.IO; System.Diagnostics; System.Text.RegularExpressions;
namespace EnkDekGUI { public partial class frmNihilistEnk : Form { public frmNihilistEnk() { InitializeComponent(); } //===========================================fungsi enkripsi NIHILIST=============================================== public string EncryptMessage(string message, string keys) { char[] mesarr = message.Trim().Replace(" ","").ToLower().ToCharArray(); char[] keyarr = keys.Trim().Replace(" ", "").ToLower().ToCharArray(); int st = 0; int tt = 0; string [] strarr = new string[mesarr.Length]; string[] keyarrc = new string[mesarr.Length]; string[] numarr = new string[mesarr.Length]; string[] numkey = new string[mesarr.Length]; for (st = 0; st < mesarr.Length; st++) { strarr[st] = mesarr[st].ToString(); if (tt >= keyarr.Length) { tt = 0; } keyarrc[st] = keyarr[tt].ToString(); tt++; } st = 0; foreach (string c in strarr) { switch (c) { //memilih karakter ke-c case "a": numarr[st] = getchar("A"); break; case "b": numarr[st] = getchar("B"); break; case "c":
Universitas Sumatera Utara
A-3
numarr[st] break; case "d": numarr[st] break; case "e": numarr[st] break; case "f": numarr[st] break; case "g": numarr[st] break; case "h": numarr[st] break; case "i": numarr[st] break; case "j": numarr[st] break; case "k": numarr[st] break; case "l": numarr[st] break; case "m": numarr[st] break; case "n": numarr[st] break; case "o": numarr[st] break; case "p": numarr[st] break; case "q": numarr[st] break; case "r": numarr[st] break; case "s": numarr[st] break; case "t": numarr[st] break; case "u": numarr[st] break; case "v": numarr[st] break; case "w":
= getchar("C"); = getchar("D"); = getchar("E"); = getchar("F"); = getchar("G"); = getchar("H"); = getchar("I"); = getchar("I"); = getchar("K"); = getchar("L"); = getchar("M"); = getchar("N"); = getchar("O"); = getchar("P"); = getchar("Q"); = getchar("R"); = getchar("S"); = getchar("T"); = getchar("U"); = getchar("V");
Universitas Sumatera Utara
A-4
numarr[st] break; case "x": numarr[st] break; case "y": numarr[st] break; case "z": numarr[st] break;
= getchar("W"); = getchar("X"); = getchar("Y"); = getchar("Z");
} st++; } st = 0; foreach (string c in keyarrc) { switch (c) { //memilih karakter ke-c case "a": numkey[st] = getchar("A"); break; case "b": numkey[st] = getchar("B"); break; case "c": numkey[st] = getchar("C"); break; case "d": numkey[st] = getchar("D"); break; case "e": numkey[st] = getchar("E"); break; case "f": numkey[st] = getchar("F"); break; case "g": numkey[st] = getchar("G"); break; case "h": numkey[st] = getchar("H"); break; case "i": numkey[st] = getchar("I"); break; case "j": numkey[st] = getchar("I"); break; case "k": numkey[st] = getchar("K"); break; case "l": numkey[st] = getchar("L"); break; case "m": numkey[st] = getchar("M");
Universitas Sumatera Utara
A-5
break; case "n": numkey[st] break; case "o": numkey[st] break; case "p": numkey[st] break; case "q": numkey[st] break; case "r": numkey[st] break; case "s": numkey[st] break; case "t": numkey[st] break; case "u": numkey[st] break; case "v": numkey[st] break; case "w": numkey[st] break; case "x": numkey[st] break; case "y": numkey[st] break; case "z": numkey[st] break;
= getchar("N"); = getchar("O"); = getchar("P"); = getchar("Q"); = getchar("R"); = getchar("S"); = getchar("T"); = getchar("U"); = getchar("V"); = getchar("W"); = getchar("X"); = getchar("Y"); = getchar("Z");
} st++; } string[] hasil = new string[numarr.Length]; string returnText = ""; for (int jsd = 0; jsd < numarr.Length; jsd++) { hasil[jsd] = (Int32.Parse(numarr[jsd]) + Int32.Parse(numkey[jsd])).ToString(); } //deklarasi variabel returnText : var = fungsi outputText dari nilai fungsi stepOne returnText = string.Join(" ", hasil); //kembalikan fungsi enkripsi = nilai returnText return returnText; }//===========================================end of fungsi enkripsi NIHILIST===============================================
Universitas Sumatera Utara
A-6
//fungsi mendapatkan karakter tertentu dari textbox private string getchar(string kar) { //deklarasi variabel has : string; string has = ""; if (AA.Text.ToUpper() == kar) has = "11"; else if (AB.Text.ToUpper() == kar) has = "12"; else if (AC.Text.ToUpper() == kar) has = "13"; else if (AD.Text.ToUpper() == kar) has = "14"; else if (AE.Text.ToUpper() == kar) has = "15"; else if (BA.Text.ToUpper() == kar) has = "21"; else if (BB.Text.ToUpper() == kar) has = "22"; else if (BC.Text.ToUpper() == kar) has = "23"; else if (BD.Text.ToUpper() == kar) has = "24"; else if (BE.Text.ToUpper() == kar) has = "25"; else if (CA.Text.ToUpper() == kar) has = "31"; else if (CB.Text.ToUpper() == kar) has = "32"; else if (CC.Text.ToUpper() == kar) has = "33"; else if (CD.Text.ToUpper() == kar) has = "34"; else if (CE.Text.ToUpper() == kar) has = "35"; else if (DA.Text.ToUpper() == kar) has = "41"; else if (DB.Text.ToUpper() == kar) has = "42"; else if (DC.Text.ToUpper() == kar) has = "43"; else if (DD.Text.ToUpper() == kar) has = "44"; else if (DE.Text.ToUpper() == kar) has = "45"; else if (EA.Text.ToUpper() == kar) has = "51"; else if (EB.Text.ToUpper() == kar) has = "52"; else if (EC.Text.ToUpper() == kar) has = "53"; else if (ED.Text.ToUpper() == kar) has = "54"; else if (EE.Text.ToUpper() == kar) has = "55"; //kembalikan fungsi getChar = nilai has return has; }
Universitas Sumatera Utara
A-7
private void button1_Click(object sender, EventArgs e) { if (txtRead.Text != "" || txtRead.Text == " ") { if (txtKunci.Text != "" || txtKunci.Text == " ") { if (AA.Text == "" || BA.Text == "" || CA.Text == "" || DA.Text == "" || EA.Text == "" || AB.Text == "" || BB.Text == "" || CB.Text == "" || DB.Text == "" || EB.Text == "" || AC.Text == "" || BC.Text == "" || CC.Text == "" || DC.Text == "" || EC.Text == "" || AD.Text == "" || BD.Text == "" || CD.Text == "" || DD.Text == "" || ED.Text == "" || AE.Text == "" || BE.Text == "" || CE.Text == "" || DE.Text == "" || EE.Text == "") { MessageBox.Show("Isian Konversi harus diisi"); } else { //validasi plaintext, matrik dan kata kunci string pattern = "^[" + AA.Text + BA.Text + CA.Text + DA.Text + EA.Text + AB.Text + BB.Text + CB.Text + DB.Text + EB.Text + AC.Text + BC.Text + CC.Text + DC.Text + EC.Text + AD.Text + BD.Text + CD.Text + DD.Text + ED.Text + AE.Text + BE.Text + CE.Text + DE.Text + EE.Text + " ]+$"; if (Regex.IsMatch(txtRead.Text.ToUpper(), pattern)) { if (Regex.IsMatch(txtKunci.Text.ToUpper(), pattern)) { //kosongkan textbox txtHasil txtHasil.Text = ""; //deklarasi variabel sw : stopwatch > menghitung waktu proses Stopwatch sw = Stopwatch.StartNew(); //menambahkan text kedalam textbox txtHasil dengan hasil enkripsi dari txtRead txtHasil.AppendText(EncryptMessage(txtRead.Text, txtKunci.Text.ToUpper())); //sw stop sw.Stop(); //mengambil waktu dalam satuan ms kemudian tampilkan ke textbox lblwaktu lblWaktu.Text = sw.Elapsed.Milliseconds.ToString() + " ms"; //tampilkan ke textbox lblPanjangKar = panjang karakter dari txtHasil (enkripsi) lblPanjangKar.Text = txtHasil.Text.Length.ToString(); }
Universitas Sumatera Utara
A-8
else { MessageBox.Show("Karakter pada Teks Kunci tidak ada di isian Konversi"); } } else { MessageBox.Show("Karakter pada plaintext tidak ada di isian Konversi"); } } } else { MessageBox.Show("Teks Kunci masih kosong"); } } else { MessageBox.Show("Plaintext masih kosong"); } } //fungsi tombol simpan hasil enkripsi private void button2_Click(object sender, EventArgs e) { //coba lakukan try { //deklarasi variabel result: dialog = dialog simpan file DialogResult result = saveFileDialog1.ShowDialog(); //jika result = OK if (result == DialogResult.OK) { //simpan textbox hasil menjadi filename File.WriteAllText(@saveFileDialog1.FileName, txtHasil.Text); //tampilkan pesan berhasil MessageBox.Show("File berhasil disimpan!"); } } //jika terdapat error catch (Exception err) { //tampilkan pesan error MessageBox.Show(err.ToString(), "Error"); } } //fungsi tombol browse file private void btnBrowseInput_Click(object sender, EventArgs e) { //deklarasi variabel result: dialog = dialog buka file DialogResult result = openFileDialog1.ShowDialog(); //jika result = OK if (result == DialogResult.OK) {
Universitas Sumatera Utara
A-9
//textbox txtfile = namafile txtFile.Text = openFileDialog1.FileName; //kosongkan textbox txtread txtRead.Text = ""; //deklarasi formatfile:string = ekstensi dari namafile string formatfile = Path.GetExtension(@txtFile.Text); //jika txt if (formatfile == ".txt") //textbox txtread diisi text dari file text txtRead.AppendText(File.ReadAllText(@txtFile.Text)); //jika doc atau docx else if (formatfile == ".doc" || formatfile == ".docx") //textbox txtread diisi text dari file doc atau docx txtRead.AppendText(Utility.gettextfromword(@txtFile.Text)); //jika tidak ada else //textbox txtread dikosongkan txtRead.Text = ""; } } //fungsi tombol reset form private void button3_Click(object sender, EventArgs e) { //kembalikan textbox ke nilai awal txtFile.Text = ""; txtHasil.Text = ""; txtKunci.Text = ""; txtRead.Text = ""; AA.Text AB.Text AC.Text AD.Text AE.Text BA.Text
= = = = = =
""; ""; ""; ""; ""; "";
BB.Text BC.Text BD.Text BE.Text CA.Text CB.Text
= = = = = =
""; ""; ""; ""; ""; "";
CC.Text CD.Text CE.Text DA.Text DB.Text DC.Text
= = = = = =
""; ""; ""; ""; ""; "";
DD.Text = ""; DE.Text = ""; EA.Text = "";
Universitas Sumatera Utara
A-10
EB.Text = ""; EC.Text = ""; ED.Text = ""; EE.Text EB.Text EC.Text ED.Text EE.Text
= = = = =
""; ""; ""; ""; "";
} } }
Kode Program Nihilist Dekripsi.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using Microsoft.Office.Interop.Word; using System.Diagnostics; using System.Text.RegularExpressions; namespace EnkDekGUI { public partial class frmNihilistDek : Form { public frmNihilistDek() { InitializeComponent(); } //===========================================fungsi dekripsi ADFGVX=============================================== public string DecryptMessage(string messchip,string keyText) { string[] mesarr = messchip.Split(' '); char[] keyarr = keyText.Trim().Replace(" ", "").ToLower().ToCharArray(); int st = 0; int tt = 0; string[] keyarrc = new string[mesarr.Length]; string[] numkey = new string[mesarr.Length]; for (st = 0; st < mesarr.Length; st++) { if (tt >= keyarr.Length) { tt = 0; } keyarrc[st] = keyarr[tt].ToString(); tt++; }
Universitas Sumatera Utara
A-11
st = 0; foreach (string c in keyarrc) { switch (c) { //memilih karakter ke-c case "a": numkey[st] = getchar("A"); break; case "b": numkey[st] = getchar("B"); break; case "c": numkey[st] = getchar("C"); break; case "d": numkey[st] = getchar("D"); break; case "e": numkey[st] = getchar("E"); break; case "f": numkey[st] = getchar("F"); break; case "g": numkey[st] = getchar("G"); break; case "h": numkey[st] = getchar("H"); break; case "i": numkey[st] = getchar("I"); break; case "j": numkey[st] = getchar("J"); break; case "k": numkey[st] = getchar("K"); break; case "l": numkey[st] = getchar("L"); break; case "m": numkey[st] = getchar("M"); break; case "n": numkey[st] = getchar("N"); break; case "o": numkey[st] = getchar("O"); break; case "p": numkey[st] = getchar("P"); break; case "q": numkey[st] = getchar("Q"); break; case "r": numkey[st] = getchar("R");
Universitas Sumatera Utara
A-12
break; case "s": numkey[st] break; case "t": numkey[st] break; case "u": numkey[st] break; case "v": numkey[st] break; case "w": numkey[st] break; case "x": numkey[st] break; case "y": numkey[st] break; case "z": numkey[st] break; case "0": numkey[st] break; case "1": numkey[st] break; case "2": numkey[st] break; case "3": numkey[st] break; case "4": numkey[st] break; case "5": numkey[st] break; case "6": numkey[st] break; case "7": numkey[st] break; case "8": numkey[st] break; case "9": numkey[st] break;
= getchar("S"); = getchar("T"); = getchar("U"); = getchar("V"); = getchar("W"); = getchar("X"); = getchar("Y"); = getchar("Z"); = getchar("0"); = getchar("1"); = getchar("2"); = getchar("3"); = getchar("4"); = getchar("5"); = getchar("6"); = getchar("7"); = getchar("8"); = getchar("9");
} st++; } string[] hasil = new string[mesarr.Length];
Universitas Sumatera Utara
A-13
string returnText = ""; string temps = ""; for (int jsd = 0; jsd < mesarr.Length ; jsd++) { temps = (Int32.Parse(mesarr[jsd]) Int32.Parse(numkey[jsd])).ToString(); switch (temps) { case "11": hasil[jsd] break; case "12": hasil[jsd] break; case "13": hasil[jsd] break; case "14": hasil[jsd] break; case "15": hasil[jsd] break; case "21": hasil[jsd] break; case "22": hasil[jsd] break; case "23": hasil[jsd] break; case "24": hasil[jsd] break; case "25": hasil[jsd] break; case "31": hasil[jsd] break; case "32": hasil[jsd] break; case "33": hasil[jsd] break; case "34": hasil[jsd] break; case "35": hasil[jsd] break;
= hurufbesar(AA.Text); = hurufbesar(AB.Text); = hurufbesar(AC.Text); = hurufbesar(AD.Text); = hurufbesar(AE.Text); = hurufbesar(BA.Text); = hurufbesar(BB.Text); = hurufbesar(BC.Text); = hurufbesar(BD.Text); = hurufbesar(BE.Text); = hurufbesar(CA.Text); = hurufbesar(CB.Text); = hurufbesar(CC.Text); = hurufbesar(CD.Text); = hurufbesar(CE.Text);
case "41": hasil[jsd] = hurufbesar(DA.Text); break; case "42": hasil[jsd] = hurufbesar(DB.Text);
Universitas Sumatera Utara
A-14
break; case "43": hasil[jsd] = hurufbesar(DC.Text); break; case "44": hasil[jsd] = hurufbesar(DD.Text); break; case "45": hasil[jsd] = hurufbesar(DE.Text); break; case "51": hasil[jsd] break; case "52": hasil[jsd] break; case "53": hasil[jsd] break; case "54": hasil[jsd] break; case "55": hasil[jsd] break;
= hurufbesar(EA.Text); = hurufbesar(EB.Text); = hurufbesar(EC.Text); = hurufbesar(ED.Text); = hurufbesar(EE.Text);
} } //deklarasi variabel returnText : var = fungsi outputText dari nilai fungsi stepOne returnText = string.Join("", hasil); //kembalikan fungsi dekripsi = nilai returnText return returnText; }//===========================================end of fungsi dekripsi ADFGVX=============================================== //fungsi mendapatkan karakter tertentu dari textbox private string getchar(string kar) { //deklarasi variabel has : string; string has = ""; if (AA.Text.ToUpper() == kar) has = "11"; else if (AB.Text.ToUpper() == kar) has = "12"; else if (AC.Text.ToUpper() == kar) has = "13"; else if (AD.Text.ToUpper() == kar) has = "14"; else if (AE.Text.ToUpper() == kar) has = "15"; else if (BA.Text.ToUpper() == kar) has = "21"; else if (BB.Text.ToUpper() == kar) has = "22"; else if (BC.Text.ToUpper() == kar) has = "23";
Universitas Sumatera Utara
A-15
else if has else if has else if has else if has else if has else if has else if has
(BD.Text.ToUpper() = "24"; (BE.Text.ToUpper() = "25"; (CA.Text.ToUpper() = "31"; (CB.Text.ToUpper() = "32"; (CC.Text.ToUpper() = "33"; (CD.Text.ToUpper() = "34"; (CE.Text.ToUpper() = "35";
== kar) == kar) == kar) == kar) == kar) == kar) == kar)
else if (DA.Text.ToUpper() == has = "41"; else if (DB.Text.ToUpper() == has = "42"; else if (DC.Text.ToUpper() == has = "43"; else if (DD.Text.ToUpper() == has = "44"; else if (DE.Text.ToUpper() == has = "45"; else if (EA.Text.ToUpper() == has = "51"; else if (EB.Text.ToUpper() == has = "52"; else if (EC.Text.ToUpper() == has = "53"; else if (ED.Text.ToUpper() == has = "54"; else if (EE.Text.ToUpper() == has = "55"; //kembalikan fungsi getChar = return has;
kar) kar) kar) kar) kar) kar) kar) kar) kar) kar) nilai has
} //fungsi membuat huruf besar public string hurufbesar(string s) { //kembalikan fungsi hurufbesar = s diubah menjadi huruf besar return s.ToUpper(); } private void button1_Click(object sender, EventArgs e) { if (txtRead.Text != "") { if (txtKunci.Text != "") { if (AA.Text == "" || BA.Text == "" || CA.Text == "" || DA.Text == "" || EA.Text == "" || AB.Text == "" || BB.Text == "" || CB.Text == "" || DB.Text == "" || EB.Text
Universitas Sumatera Utara
A-16
== "" || AC.Text == "" || BC.Text == "" || CC.Text == "" || DC.Text == "" || EC.Text == "" || AD.Text == "" || BD.Text == "" || CD.Text == "" || DD.Text == "" || ED.Text == "" || AE.Text == "" || BE.Text == "" || CE.Text == "" || DE.Text == "" || EE.Text == "") { MessageBox.Show("Isian Konversi harus diisi"); } else { //validasi plaintext, matrik dan kata kunci string pattern = "^[" + AA.Text + BA.Text + CA.Text + DA.Text + EA.Text + AB.Text + BB.Text + CB.Text + DB.Text + EB.Text + AC.Text + BC.Text + CC.Text + DC.Text + EC.Text + AD.Text + BD.Text + CD.Text + DD.Text + ED.Text + AE.Text + BE.Text + CE.Text + DE.Text + EE.Text + " ]+$"; string pattern2 = "^[0-9 ]+$"; if (Regex.IsMatch(txtRead.Text.ToUpper(), pattern2)) { if (Regex.IsMatch(txtKunci.Text.ToUpper(), pattern)) { //kosongkan textbox txtHasil txtHasil.Text = ""; //deklarasi variabel sw : stopwatch -> menghitung waktu proses Stopwatch sw = Stopwatch.StartNew(); //menambahkan text kedalam textbox txtHasil dengan hasil dekripsi dari txtRead txtHasil.AppendText(DecryptMessage(txtRead.Text, txtKunci.Text)); //sw stop sw.Stop(); //mengambil waktu dalam satuan ms kemudian tampilkan ke textbox lblwaktu lblWaktu.Text = sw.Elapsed.Milliseconds.ToString() + " ms"; //tampilkan ke textbox lblPanjangKar = panjang karakter dari txtHasil (dekripsi) lblPanjangKar.Text = txtHasil.Text.Length.ToString(); } else { MessageBox.Show("Karakter pada Teks Kunci tidak ada di isian Konversi"); } } else { MessageBox.Show("Karakter pada plaintext tidak ada di isian Konversi"); }
Universitas Sumatera Utara
A-17
} } else { MessageBox.Show("Teks kunci masih kosong"); } } else { MessageBox.Show("Plaintext masih kosong"); } } //fungsi tombol simpan hasil dekripsi private void button2_Click(object sender, EventArgs e) { //coba lakukan try { //deklarasi variabel result: dialog = dialog simpan file DialogResult result = saveFileDialog1.ShowDialog(); //jika result = OK if (result == DialogResult.OK) { //deklarasi formatfile:string = ekstensi dari namafile string formatfile = Path.GetExtension(@saveFileDialog1.FileName); //jika txt if (formatfile == ".txt") //simpan textbox hasil menjadi filename tipe txt File.WriteAllText(@saveFileDialog1.FileName, txtHasil.Text); else { //simpan textbox hasil menjadi filename tipe doc atau docx Utility.savetexttoword(txtHasil.Text, saveFileDialog1.FileName); } //tampilkan pesan berhasil MessageBox.Show("File berhasil disimpan!"); } } //jika terdapat error catch (Exception err) { //tampilkan pesan error MessageBox.Show(err.ToString(), "Error"); } } //fungsi tombol browse file private void btnBrowseInput_Click(object sender, EventArgs e) { //deklarasi variabel result: dialog = dialog buka file
Universitas Sumatera Utara
A-18
DialogResult result = openFileDialog1.ShowDialog(); //jika result = OK if (result == DialogResult.OK) { //textbox txtfile = namafile txtFile.Text = openFileDialog1.FileName; //kosongkan textbox txtread txtRead.Text = ""; //textbox txtread diisi text dari txtFile txtRead.AppendText(File.ReadAllText(@txtFile.Text)); } } //fungsi tombol reset form private void button3_Click(object sender, EventArgs e) { //kembalikan textbox ke nilai awal txtFile.Text = ""; txtHasil.Text = ""; txtKunci.Text = ""; txtRead.Text = ""; AA.Text AB.Text AC.Text AD.Text AE.Text
= = = = =
""; ""; ""; ""; "";
BA.Text BB.Text BC.Text BD.Text BE.Text
= = = = =
""; ""; ""; ""; "";
CA.Text CB.Text CC.Text CD.Text CE.Text
= = = = =
""; ""; ""; ""; "";
DA.Text DB.Text DC.Text DD.Text DE.Text
= = = = =
""; ""; ""; ""; "";
EA.Text EB.Text EC.Text ED.Text EE.Text
= = = = =
""; ""; ""; ""; "";
} } }
Universitas Sumatera Utara
A-19
Kode Program Enkripsi.cs using using using using using using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; Microsoft.Office.Interop.Word; System.IO; System.Diagnostics; System.Text.RegularExpressions;
namespace EnkDekGUI { public partial class frmEnkripsi : Form { public frmEnkripsi() { InitializeComponent(); } //===========================================fungsi enkripsi ADFGVX=============================================== public string EncryptMessage(string message) { //deklarasi variabel stepOne : var = fungsi stepOne dari message yang di huruf kecil. var stepOne = StepOne(message.ToLower()); //deklarasi variabel returnText : var = fungsi outputText dari nilai fungsi stepOne var returnText = OutputText(stepOne); //kembalikan fungsi enkripsi = nilai returnText return returnText; }//===========================================end of fungsi enkripsi ADFGVX=============================================== //fungsi untuk membersihkan string message private string CleanMessage(string message) { //deklarasi variabel sb : string builder = fungsi string builder baru StringBuilder sb = new StringBuilder(); //pengulangan untuk pembersihan masing-masing message foreach (char c in message) { //memilih karakter ke-c switch (c) { case '\r': case '\n': case '\t': case ' ': continue; default: sb.Append(c); break;
Universitas Sumatera Utara
A-20
} } //kembalikan fungsi CleanMessage = konversi string sb menjadi string dan diubah huruf kecil return sb.ToString().ToLower(); } //fungsi untuk mengisi kolom dan metranspose baris menjadi kolom private string OutputText(string message) { //deklarasi variabel counter : var = 0 var counter = 0; //membuat kolom dari kunci var columnTransposition = txtKunci.Text.Distinct().ToDictionary(c => c, c => new List
()); //pengulangan untuk mentranspose sebanyak message foreach (var each in message) { //mentranspose karakter sesuai kolom kunci columnTransposition[txtKunci.Text[counter]].Add(each); //menambahkan 1 step nilai counter counter++; //jika counter >= txtKunci if (counter >= txtKunci.Text.Length) //reset counter menjadi 0 counter = 0; } //deklarasi variabel sb : var = fungsi string builder var sb = new StringBuilder(); //deklarasi variabel alphabeticalString : var = textbox kunci diubah menjadi bentuk list var alphabeticalKey = txtKunci.Text.ToList(); //mengurutkan secara alphebet list kunci alphabeticalKey.Sort(); //pengulangan untuk pengisian string kedalam kolom kolom kunci foreach (var c in alphabeticalKey) { //mengisi masing-masing kolom kunci ke-c dengan string message foreach (var each in columnTransposition[c]) { //menambahkan string ke sb sb.Append(each); } //memberi spasi diakhir kolom sb.Append(' '); } //kembalikan fungsi OutputText = konversi sb menjadi string return sb.ToString(); } //fungsi mengganti string ADFGVX menjadi plaintext private string StepOne(string cleanedMessage) {
Universitas Sumatera Utara
A-21
//deklarasi variabel sb : string builder = fungsi string builder baru StringBuilder sb = new StringBuilder(); //pengulangan untuk pembersihan masing-masing message foreach (char c in cleanedMessage) { switch (c) { //memilih karakter ke-c case 'a': sb.Append(getchar("A")); break; case 'b': sb.Append(getchar("B")); break; case 'c': sb.Append(getchar("C")); break; case 'd': sb.Append(getchar("D")); break; case 'e': sb.Append(getchar("E")); break; case 'f': sb.Append(getchar("F")); break; case 'g': sb.Append(getchar("G")); break; case 'h': sb.Append(getchar("H")); break; case 'i': sb.Append(getchar("I")); break; case 'j': sb.Append(getchar("J")); break; case 'k': sb.Append(getchar("K")); break; case 'l': sb.Append(getchar("L")); break; case 'm': sb.Append(getchar("M")); break; case 'n': sb.Append(getchar("N")); break; case 'o': sb.Append(getchar("O")); break; case 'p': sb.Append(getchar("P")); break; case 'q': sb.Append(getchar("Q")); break;
Universitas Sumatera Utara
A-22
case 'r': sb.Append(getchar("R")); break; case 's': sb.Append(getchar("S")); break; case 't': sb.Append(getchar("T")); break; case 'u': sb.Append(getchar("U")); break; case 'v': sb.Append(getchar("V")); break; case 'w': sb.Append(getchar("W")); break; case 'x': sb.Append(getchar("X")); break; case 'y': sb.Append(getchar("Y")); break; case 'z': sb.Append(getchar("Z")); break; case '0': sb.Append(getchar("0")); break; case '1': sb.Append(getchar("1")); break; case '2': sb.Append(getchar("2")); break; case '3': sb.Append(getchar("3")); break; case '4': sb.Append(getchar("4")); break; case '5': sb.Append(getchar("5")); break; case '6': sb.Append(getchar("6")); break; case '7': sb.Append(getchar("7")); break; case '8': sb.Append(getchar("8")); break; case '9': sb.Append(getchar("9")); break; } }
Universitas Sumatera Utara
A-23
//kembalikan fungsi CleanMessage = konversi string sb menjadi string return sb.ToString(); } //fungsi mendapatkan karakter tertentu dari textbox private string getchar(string kar) { //deklarasi variabel has : string; string has = ""; if (AA.Text.ToUpper() == kar) has = "AA"; else if (AD.Text.ToUpper() == kar) has = "AD"; else if (AF.Text.ToUpper() == kar) has = "AF"; else if (AG.Text.ToUpper() == kar) has = "AG"; else if (AV.Text.ToUpper() == kar) has = "AV"; else if (AX.Text.ToUpper() == kar) has = "AX"; else if (DA.Text.ToUpper() == kar) has = "DA"; else if (DD.Text.ToUpper() == kar) has = "DD"; else if (DF.Text.ToUpper() == kar) has = "DF"; else if (DG.Text.ToUpper() == kar) has = "DG"; else if (DV.Text.ToUpper() == kar) has = "DV"; else if (DX.Text.ToUpper() == kar) has = "DX"; else if (FA.Text.ToUpper() == kar) has = "FA"; else if (FD.Text.ToUpper() == kar) has = "FD"; else if (FF.Text.ToUpper() == kar) has = "FF"; else if (FG.Text.ToUpper() == kar) has = "FG"; else if (FV.Text.ToUpper() == kar) has = "FV"; else if (FX.Text.ToUpper() == kar) has = "FX"; else if (GA.Text.ToUpper() == kar) has = "GA"; else if (GD.Text.ToUpper() == kar) has = "GD"; else if (GF.Text.ToUpper() == kar) has = "GF"; else if (GG.Text.ToUpper() == kar) has = "GG"; else if (GV.Text.ToUpper() == kar) has = "GV"; else if (GX.Text.ToUpper() == kar) has = "GX"; else if (VA.Text.ToUpper() == kar) has = "VA";
Universitas Sumatera Utara
A-24
else if (VD.Text.ToUpper() == has = "VD"; else if (VF.Text.ToUpper() == has = "VF"; else if (VG.Text.ToUpper() == has = "VG"; else if (VV.Text.ToUpper() == has = "VV"; else if (VX.Text.ToUpper() == has = "VX"; else if (XA.Text.ToUpper() == has = "XA"; else if (XD.Text.ToUpper() == has = "XD"; else if (XF.Text.ToUpper() == has = "XF"; else if (XG.Text.ToUpper() == has = "XG"; else if (XV.Text.ToUpper() == has = "XV"; else if (XX.Text.ToUpper() == has = "XX"; //kembalikan fungsi getChar = return has;
kar) kar) kar) kar) kar) kar) kar) kar) kar) kar) kar) nilai has
} private void button1_Click(object sender, EventArgs e) { if (txtRead.Text != "") { if (txtKunci.Text != "") { if (AA.Text == "" || DA.Text == "" || FA.Text == "" || GA.Text == "" || VA.Text == "" || XA.Text == "" || AD.Text == "" || DD.Text == "" || FD.Text == "" || GD.Text == "" || VD.Text == "" || XD.Text == "" || AF.Text == "" || DF.Text == "" || FF.Text == "" || GF.Text == "" || VF.Text == "" || XF.Text == "" || AG.Text == "" || DG.Text == "" || FG.Text == "" || GG.Text == "" || VG.Text == "" || XG.Text == "" || AV.Text == "" || DV.Text == "" || FV.Text == "" || GV.Text == "" || VV.Text == "" || XV.Text == "" || AX.Text == "" || DX.Text == "" || FX.Text == "" || GX.Text == "" || VX.Text == "" || XX.Text == "" ) { MessageBox.Show("Isian Konversi harus diisi"); } else { //validasi plaintext, matrik dan kata kunci string pattern = "^[" + AA.Text + DA.Text + FA.Text + GA.Text + VA.Text + XA.Text + AD.Text + DD.Text + FD.Text + GD.Text + VD.Text + XD.Text + AF.Text + DF.Text + FF.Text + GF.Text + VF.Text + XF.Text + AG.Text + DG.Text + FG.Text + GG.Text + VG.Text + XG.Text + AV.Text + DV.Text + FV.Text + GV.Text + VV.Text + XV.Text
Universitas Sumatera Utara
A-25
+ AX.Text + DX.Text + FX.Text + GX.Text + VX.Text + XX.Text + " ]+$"; if (Regex.IsMatch(txtRead.Text.ToUpper(), pattern)) { if (Regex.IsMatch(txtKunci.Text.ToUpper(), pattern)) { //kosongkan textbox txtHasil txtHasil.Text = ""; //deklarasi variabel sw : stopwatch -> menghitung waktu proses Stopwatch sw = Stopwatch.StartNew(); //menambahkan text kedalam textbox txtHasil dengan hasil enkripsi dari txtRead txtHasil.AppendText(EncryptMessage(txtRead.Text)); //sw stop sw.Stop(); //mengambil waktu dalam satuan ms kemudian tampilkan ke textbox lblwaktu lblWaktu.Text = sw.Elapsed.Milliseconds.ToString() + " ms"; //tampilkan ke textbox lblPanjangKar = panjang karakter dari txtHasil (enkripsi) lblPanjangKar.Text = txtHasil.Text.Length.ToString(); } else { MessageBox.Show("Karakter pada Teks Kunci tidak ada di isian Konversi"); } } else { MessageBox.Show("Karakter pada plaintext tidak ada di isian Konversi"); } } } else { MessageBox.Show("Teks Kunci masih kosong"); } } else { MessageBox.Show("Plaintext masih kosong"); } }
Universitas Sumatera Utara
A-26
//fungsi tombol simpan hasil enkripsi private void button2_Click(object sender, EventArgs e) { //coba lakukan try { //deklarasi variabel result: dialog = dialog simpan file DialogResult result = saveFileDialog1.ShowDialog(); //jika result = OK if (result == DialogResult.OK) { //simpan textbox hasil menjadi filename File.WriteAllText(@saveFileDialog1.FileName, txtHasil.Text); //tampilkan pesan berhasil MessageBox.Show("File berhasil disimpan!"); } } //jika terdapat error catch (Exception err) { //tampilkan pesan error MessageBox.Show(err.ToString(), "Error"); } } //fungsi tombol browse file private void btnBrowseInput_Click(object sender, EventArgs e) { //deklarasi variabel result: dialog = dialog buka file DialogResult result = openFileDialog1.ShowDialog(); //jika result = OK if (result == DialogResult.OK) { //textbox txtfile = namafile txtFile.Text = openFileDialog1.FileName; //kosongkan textbox txtread txtRead.Text = ""; //deklarasi formatfile:string = ekstensi dari namafile string formatfile = Path.GetExtension(@txtFile.Text); //jika txt if (formatfile == ".txt") //textbox txtread diisi text dari file text txtRead.AppendText(File.ReadAllText(@txtFile.Text)); //jika doc atau docx else if (formatfile == ".doc" || formatfile == ".docx") //textbox txtread diisi text dari file doc atau docx txtRead.AppendText(Utility.gettextfromword(@txtFile.Text)); //jika tidak ada else //textbox txtread dikosongkan
Universitas Sumatera Utara
A-27
txtRead.Text = ""; } } //fungsi tombol reset form private void button3_Click(object sender, EventArgs e) { //kembalikan textbox ke nilai awal txtFile.Text = ""; txtHasil.Text = ""; txtKunci.Text = ""; txtRead.Text = ""; AA.Text AD.Text AF.Text AG.Text AV.Text AX.Text
= = = = = =
""; ""; ""; ""; ""; "";
DA.Text DD.Text DF.Text DG.Text DV.Text DX.Text
= = = = = =
""; ""; ""; ""; ""; "";
FA.Text FD.Text FF.Text FG.Text FV.Text FX.Text
= = = = = =
""; ""; ""; ""; ""; "";
GA.Text GD.Text GF.Text GG.Text GV.Text GX.Text
= = = = = =
""; ""; ""; ""; ""; "";
VA.Text VD.Text VF.Text VG.Text VV.Text VX.Text
= = = = = =
""; ""; ""; ""; ""; "";
XA.Text XD.Text XF.Text XG.Text XV.Text XX.Text
= = = = = =
""; ""; ""; ""; ""; "";
} } }
Universitas Sumatera Utara
A-28
Kode Program Dekripsi.cs using using using using using using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.IO; Microsoft.Office.Interop.Word; System.Diagnostics; System.Text.RegularExpressions;
namespace EnkDekGUI { public partial class frmDekripsi : Form { public frmDekripsi() { InitializeComponent(); } //===========================================fungsi dekripsi ADFGVX=============================================== public string DecryptMessage(string cipherText) { //deklarasi array string splitChiper = chipertext dipisahkan dengan ' ' string[] splitCipher = cipherText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); //deklarasi transformedCipher : var = fungsi transformChiper dari splitchiper var transformedCipher = TransformCipher(splitCipher); //deklarasi returntext : var = fungsi ReverseStepOne dari transformedChiper var returnText = ReverseStepOne(transformedCipher); //kembalikan fungsi dekripsi = nilai returnText return returnText; }//===========================================end of fungsi dekripsi ADFGVX=============================================== //fungsi pembalikan private string ReverseStepOne(string transformedCipher) { //deklarasi sb: var = stringbuilder var sb = new StringBuilder(); //perulangan untuk menambahkan string sb for (int i = 1; i < transformedCipher.Length; i += 2) { //tambahkan sb dari fungsi getplaintext dari array transformedCipher ke-i sampai transformedCipher ke-i) sb.Append(GetPlainText(transformedCipher[i - 1], transformedCipher[i])); } //kembalikan fungsi ReverseStepOne = konvernsi sb menjadi string return sb.ToString(); }
Universitas Sumatera Utara
A-29
//fungsi membuat huruf besar public string hurufbesar(string s) { //kembalikan fungsi hurufbesar = s diubah menjadi huruf besar return s.ToUpper(); } //fungsi mengganti plain text menjadi string ADFGVX private string GetPlainText(char c, char c1) { //deklarasi variabel sb: var = fungsi string builder var sb = new StringBuilder(); //deklarasi variabel sb: var = fungsi string builder var sb2 = new StringBuilder(); //menambahkan baris sb2 dengan c sb2.Append(c); //menambahkan baris sb2 dengan c1 sb2.Append(c1); //mengganti string sb2 dengan string sesuai textbox switch (sb2.ToString()) { case "AA": sb.Append(hurufbesar(AA.Text)); break; case "AD": sb.Append(hurufbesar(AD.Text)); break; case "AF": sb.Append(hurufbesar(AF.Text)); break; case "AG": sb.Append(hurufbesar(AG.Text)); break; case "AV": sb.Append(hurufbesar(AV.Text)); break; case "AX": sb.Append(hurufbesar(AX.Text)); break; case "DA": sb.Append(hurufbesar(DA.Text)); break; case "DD": sb.Append(hurufbesar(DD.Text)); break; case "DF": sb.Append(hurufbesar(DF.Text)); break; case "DG": sb.Append(hurufbesar(DG.Text)); break; case "DV": sb.Append(hurufbesar(DV.Text)); break; case "DX": sb.Append(hurufbesar(DX.Text)); break; case "FA":
Universitas Sumatera Utara
A-30
sb.Append(hurufbesar(FA.Text)); break; case "FD": sb.Append(hurufbesar(FD.Text)); break; case "FF": sb.Append(hurufbesar(FF.Text)); break; case "FG": sb.Append(hurufbesar(FG.Text)); break; case "FV": sb.Append(hurufbesar(FV.Text)); break; case "FX": sb.Append(hurufbesar(FX.Text)); break; case "GA": sb.Append(hurufbesar(GA.Text)); break; case "GD": sb.Append(hurufbesar(GD.Text)); break; case "GF": sb.Append(hurufbesar(GF.Text)); break; case "GG": sb.Append(hurufbesar(GG.Text)); break; case "GV": sb.Append(hurufbesar(GV.Text)); break; case "GX": sb.Append(hurufbesar(GX.Text)); break; case "VA": sb.Append(hurufbesar(VA.Text)); break; case "VD": sb.Append(hurufbesar(VD.Text)); break; case "VF": sb.Append(hurufbesar(VF.Text)); break; case "VG": sb.Append(hurufbesar(VG.Text)); break; case "VV": sb.Append(hurufbesar(VV.Text)); break; case "VX": sb.Append(hurufbesar(VX.Text)); break; case "XA": sb.Append(hurufbesar(XA.Text)); break; case "XD": sb.Append(hurufbesar(XD.Text)); break; case "XF":
Universitas Sumatera Utara
A-31
sb.Append(hurufbesar(XF.Text)); break; case "XG": sb.Append(hurufbesar(XG.Text)); break; case "XV": sb.Append(hurufbesar(XV.Text)); break; case "XX": sb.Append(hurufbesar(XX.Text)); break; } //kembalikan fungsi GetPlainText = konversi sb menjadi string return sb.ToString(); } //fungsi untuk mengisi kolom dan metranspose kolom menjadi baris public string TransformCipher(string[] splitCipher) { //deklarasi variabel alphabeticalString : var = textbox kunci diubah menjadi bentuk list var alphabeticalString = txtKunci.Text.ToList(); //mengurutkan secara alphebet list kunci alphabeticalString.Sort(); //membuat kolom dari kunci var columnTransposition = txtKunci.Text.Distinct().ToDictionary(c => c, c => new List()); //deklarasi variabel counter : var = 0 var counter = 0; //pengulangan untuk pengisian string kedalam kolom kolom kunci foreach (var c in alphabeticalString) { //mengisi masing-masing kolom kunci ke-c dengan string ADFGVX columnTransposition[c].AddRange(splitCipher[counter].ToList()); //menambahkan 1 step nilai counter counter++; } //deklarasi variabel sb : var = fungsi string builder var sb = new StringBuilder(); //deklarasi longestLength : int = fungsi mencari kolom terpanjang dari masing-masing nilai array splitChiper int longestLength = GetLongestLength(splitCipher); //pengulangan untuk mentranspose kolom menjadi baris sebanyak kolom terpanjang for (int i = 0; i < longestLength; i++) { //pengulangan untuk mentranspose sebanyak textbox kunci foreach (var c in txtKunci.Text) { //cek apakah jumlah kolom <> 0 if (columnTransposition[c].Count != 0) { //jika ya, lanjutkan //menambahkan hasil transpose ke sb
Universitas Sumatera Utara
A-32
sb.Append(columnTransposition[c].FirstOrDefault()); //mereset transpose ke posisi 0 columnTransposition[c].RemoveAt(0); } } } //kembalikan fungsi TransformChiper = konversi sb menjadi string return sb.ToString(); } //fungsi mencari kolom terpanjang pada splitChiper private int GetLongestLength(string[] splitCipher) { //deklarasi variabel largestlength : var = konversi nilai minimum menjadi int int largestLength = int.MinValue; //pengulangan untuk mencari kolom terpanjang foreach (var each in splitCipher) { //cek apakah tiap kolom lebih besar dari pembanding if (each.Length > largestLength) //jika ya, lanjutkan //pembanding = tiap kolom largestLength = each.Length; } //kembalikan fungsi GetLongestLength = largestLength return largestLength; } private void button1_Click(object sender, EventArgs e) { if (txtRead.Text != "") { if (txtKunci.Text != "") { if (AA.Text == "" || DA.Text == "" || FA.Text == "" || GA.Text == "" || VA.Text == "" || XA.Text == "" || AD.Text == "" || DD.Text == "" || FD.Text == "" || GD.Text == "" || VD.Text == "" || XD.Text == "" || AF.Text == "" || DF.Text == "" || FF.Text == "" || GF.Text == "" || VF.Text == "" || XF.Text == "" || AG.Text == "" || DG.Text == "" || FG.Text == "" || GG.Text == "" || VG.Text == "" || XG.Text == "" || AV.Text == "" || DV.Text == "" || FV.Text == "" || GV.Text == "" || VV.Text == "" || XV.Text == "" || AX.Text == "" || DX.Text == "" || FX.Text == "" || GX.Text == "" || VX.Text == "" || XX.Text == "") { MessageBox.Show("Isian Konversi harus diisi"); } else { //validasi plaintext, matrik dan kata kunci string pattern = "^[" + AA.Text + DA.Text + FA.Text + GA.Text + VA.Text + XA.Text + AD.Text + DD.Text + FD.Text + GD.Text
Universitas Sumatera Utara
A-33
+ GF.Text + VF.Text + DV.Text + FV.Text + XX.Text + " ]+$";
VD.Text + + XF.Text FG.Text + + GV.Text AX.Text +
XD.Text + + AG.Text GG.Text + + VV.Text DX.Text +
AF.Text + DF.Text + FF.Text + + DG.Text VG.Text + XG.Text + AV.Text + + XV.Text FX.Text + GX.Text + VX.Text +
string pattern2 = "^[ADFGVX ]+$"; if (Regex.IsMatch(txtRead.Text.ToUpper(), pattern2)) { if (Regex.IsMatch(txtKunci.Text.ToUpper(), pattern)) { //kosongkan textbox txtHasil txtHasil.Text = ""; //deklarasi variabel sw : stopwatch -> menghitung waktu proses Stopwatch sw = Stopwatch.StartNew(); //menambahkan text kedalam textbox txtHasil dengan hasil dekripsi dari txtRead txtHasil.AppendText(DecryptMessage(txtRead.Text)); //sw stop sw.Stop(); //mengambil waktu dalam satuan ms kemudian tampilkan ke textbox lblwaktu lblWaktu.Text = sw.Elapsed.Milliseconds.ToString() + " ms"; //tampilkan ke textbox lblPanjangKar = panjang karakter dari txtHasil (dekripsi) lblPanjangKar.Text = txtHasil.Text.Length.ToString(); } else { MessageBox.Show("Karakter pada Teks Kunci tidak ada di isian Konversi"); } } else { MessageBox.Show("Karakter pada plaintext tidak ada di isian Konversi"); } } } else { MessageBox.Show("Teks Kunci masih kosong"); } } else { MessageBox.Show("Plaintext masih kosong"); } } //fungsi tombol simpan hasil dekripsi private void button2_Click(object sender, EventArgs e) {
Universitas Sumatera Utara
A-34
//coba lakukan try { //deklarasi variabel result: dialog = dialog simpan file DialogResult result = saveFileDialog1.ShowDialog(); //jika result = OK if (result == DialogResult.OK) { //deklarasi formatfile:string = ekstensi dari namafile string formatfile = Path.GetExtension(@saveFileDialog1.FileName); //jika txt if (formatfile == ".txt") //simpan textbox hasil menjadi filename tipe txt File.WriteAllText(@saveFileDialog1.FileName, txtHasil.Text); else { //simpan textbox hasil menjadi filename tipe doc atau docx Utility.savetexttoword(txtHasil.Text, saveFileDialog1.FileName); } //tampilkan pesan berhasil MessageBox.Show("File berhasil disimpan!"); } } //jika terdapat error catch (Exception err) { //tampilkan pesan error MessageBox.Show(err.ToString(), "Error"); } } //fungsi tombol browse file private void btnBrowseInput_Click(object sender, EventArgs e) { //deklarasi variabel result: dialog = dialog buka file DialogResult result = openFileDialog1.ShowDialog(); //jika result = OK if (result == DialogResult.OK) { //textbox txtfile = namafile txtFile.Text = openFileDialog1.FileName; //kosongkan textbox txtread txtRead.Text = ""; //textbox txtread diisi text dari txtFile txtRead.AppendText(File.ReadAllText(@txtFile.Text)); } } //fungsi tombol reset form private void button3_Click(object sender, EventArgs e) { //kembalikan textbox ke nilai awal txtFile.Text = "";
Universitas Sumatera Utara
A-35
txtHasil.Text = ""; txtKunci.Text = ""; txtRead.Text = ""; AA.Text AD.Text AF.Text AG.Text AV.Text AX.Text
= = = = = =
""; ""; ""; ""; ""; "";
DA.Text DD.Text DF.Text DG.Text DV.Text DX.Text
= = = = = =
""; ""; ""; ""; ""; "";
FA.Text FD.Text FF.Text FG.Text FV.Text FX.Text
= = = = = =
""; ""; ""; ""; ""; "";
GA.Text GD.Text GF.Text GG.Text GV.Text GX.Text
= = = = = =
""; ""; ""; ""; ""; "";
VA.Text VD.Text VF.Text VG.Text VV.Text VX.Text
= = = = = =
""; ""; ""; ""; ""; "";
XA.Text XD.Text XF.Text XG.Text XV.Text XX.Text
= = = = = =
""; ""; ""; ""; ""; "";
} } }
Tentang.cs using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text;
Universitas Sumatera Utara
A-36
using System.Windows.Forms; namespace EnkDekGUI { public partial class frmTentang : Form { public frmTentang() { InitializeComponent(); } } }
Utility using using using using using using using
System; System.Collections.Generic; System.Linq; System.Text; Microsoft.Office.Interop.Word; System.IO; System.Diagnostics;
namespace EnkDekGUI { class Utility { //fungsi membaca text dari word public static string gettextfromword(string file) { //deklarasi word : application Application word = new Application(); //deklarasi miss : object = nilai missing object miss = System.Reflection.Missing.Value; //deklarasi path : object = lokasi file object path = @file; //deklarasi readonly: object = nilai true object readOnly = true; //membuat baru file word dengan lokasi file, readonly, miss Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); //deklarasi totaltext:string = "" string totaltext = ""; //perulangan untuk membaca baris perbaris paragrap for (int i = 0; i < docs.Paragraphs.Count; i++) { //totaltext += paragrap ke-i + 1 diubah menjadi string totaltext += docs.Paragraphs[i + 1].Range.Text.ToString(); } //keluar dari word ((_Application)word).Quit(); //kembalikan fungsi text dari word = totaltext return totaltext;
Universitas Sumatera Utara
A-37
} //fungsi menyimpan text ke word public static string savetexttoword(string teks, string file) { //deklarasi word : application Application word = new Application(); //deklarasi visible = nilai true word.Visible = true; //deklarasi oDoc: var = menambahkan dokumen var oDoc = word.Documents.Add(); //deklarasi par1: var = menambahkan paragrap var par1 = oDoc.Content.Paragraphs.Add(); //par1 = teks par1.Range.Text = teks; //simpan file ke lokasi file oDoc.SaveAs(@file); //keluar dari word ((_Application)word).Quit(); //kembalikan fungsi text dari word = teks return teks; } } }
Program using using using using
System; System.Collections.Generic; System.Linq; System.Windows.Forms;
namespace EnkDekGUI { static class Program { /// <summary> /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); } } }
Universitas Sumatera Utara
A-38 B-1
CURRICULUM VITAE Nama Tempat / Tanggal Lahir Alamat Agama Jenis Kelamin Alamat Email No. Hp
: Rajab Sihotang : Muara Bungo / 23Februari 1990 : Jl. Pintu Air Gg. Keluarga No. 6A : Islam : Laki-Laki : [email protected] : 08116188898
PENDIDIKAN FORMAL 2011-2013 2008-2011 2005-2008 2002-2005 1996-2002
S1 Ekstensi Ilmu Komputer Fasilkom-TI USU, Medan. D3 Teknik Informatika USU, Medan. SMA Negeri 2 Muara Bungo, Jambi SMP Negeri 4 Muara Bungo, Jambi SD Negeri 25 Muara Bungo, Jambi
SEMINAR, KURSUS 2008
2010
2010 2010
Peserta Seminar Teknologi Informasi “Welcome The Future With Information Technology” Universitas Sumatera Utara Peserta Seminar Teknologi Informasi “Workshop Networking Windows Server Work Station” Universitas Sumatera Utara Peserta Seminar Nasional “Matematika dan Terapan 2010” Universitas Sumatera Utara Peserta Seminar Internasional “Mathematics and Its Applications 2010” Universitas Sumatera Utara
KEAHLIAN Bahasa Bahasa Pemrograman
Indonesia, Inggris C++, C#.Net, PHP, MySQL.
PENGALAMAN ORGANISASI 2009 2009 2010 2010
Ketua Bidang Informasi dan Komunikasi Ikatan Mahasiswa Muslim D3 Ilmu Komputer USU Anggota Biasa HMI Ketua Bidang Informasi dan Komunikasi Pemerintahan Mahasiswa FMIPA USU Anggota Bidang Perguruan Tinggi dan Kepemudaan HMI Komisariat FMIPA USU
Universitas Sumatera Utara