• Tidak ada hasil yang ditemukan

Implementasi Kombinasi Algoritma Beaufort Dan Algoritma Spritz Dalam Skema Super Enkripsi Untuk Pengamanan Teks

N/A
N/A
Protected

Academic year: 2017

Membagikan "Implementasi Kombinasi Algoritma Beaufort Dan Algoritma Spritz Dalam Skema Super Enkripsi Untuk Pengamanan Teks"

Copied!
13
0
0

Teks penuh

(1)

LISTING PROGRAM

a.

Source Code MainForm.cs

using System;

using System.Collections.Generic; using System.Drawing;

using System.Windows.Forms; using System.Linq;

using System.Text;

using System.Diagnostics; using System.IO;

using System.Dynamic; using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System.Runtime.InteropServices; namespace skripsi_tia

{

public partial class MainForm : Form {

publicMainForm() {

InitializeComponent();

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

void BtnMasukClick(object sender, EventArgs e) {

Form1 a = newForm1(); a.Show();

this.Hide(); }

} }

b.

Source Code Form1.cs

string metode; PdfReader reader;

string runtime_beau,runtime_spritz,runtime_spritz2,runtime_beau2; int beau,spritz;

// Untuk Mencari File doc dan pdf

void BtnCariClick(object sender, EventArgs e) {

OpenFileDialog dialog = newOpenFileDialog();

(2)

dialog.RestoreDirectory = true;

if(dialog.ShowDialog() == DialogResult.OK){

metode = dialog.FileName.Substring(dialog.FileName.Length-3,3); if(metode == "doc"){

string dirName = System.IO.Path.GetDirectoryName(dialog.FileName); string drive = dirName.Split(System.IO.Path.VolumeSeparatorChar)[1]; txtCari.Text = dirName + "\\" + dialog.SafeFileName.ToString(); }

elseif(metode=="pdf"){

reader = newPdfReader(dialog.FileName); txtCari.Text = dialog.FileName; }

} }

// Untuk membuka file doc dan pdf

void BtnBukaFileClick(object sender, EventArgs e) {

var stopwatch2 = newStopwatch(); stopwatch2.Start();

if(metode=="doc"){

Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();

object filenameO = txtCari.Text.ToString(); object objFalse = false;

object objTrue = true;

object missing = System.Reflection.Missing.Value; object emptyData = string.Empty;

try{

Microsoft.Office.Interop.Word.Document aDoc

= wordApp.Documents.Open(ref filenameO, ref objFalse, ref objTrue, ref missing, ref m issing, ref missing, ref missing, ref missing, ref missing, ref missing, ref objTrue, ref missi ng, ref missing, ref missing, ref missing);

aDoc.ActiveWindow.Selection.WholeStory(); aDoc.ActiveWindow.Selection.Copy();

IDataObject data = System.Windows.Forms.Clipboard.GetDataObject(); String fileText =

data.GetData(System.Windows.Forms.DataFormats.Text).ToString(); System.Windows.Forms.Clipboard.SetDataObject(string.Empty);

txtPlaintext.Text = fileText;

stopwatch2.Stop();

(3)

}

catch(Exception err){

MessageBox.Show(err.Message); }

finally{

MessageBox.Show("File berhasil dibaca"); }

} else{

var stopwatch3 = newStopwatch(); stopwatch3.Start();

try{

int intPageNum = reader.NumberOfPages; string[] words;

string line,text; string temp="";

for (int i = 1; i <= intPageNum; i++) {

text =

PdfTextExtractor.GetTextFromPage(reader, i, newLocationTextExtractionStrategy() );

words = text.Split('\n');

for (int j = 0, len = words.Length; j < len; j++) {

line = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(words[j])); temp += line + Environment.NewLine;

} }

txtPlaintext.Text = temp;

stopwatch3.Stop();

runtime_baca.Text= (int.Parse(stopwatch3.Elapsed.ToString("fffffff"))/10000f).ToString(); }

catch(Exception err){

MessageBox.Show(err.Message); }

finally{

MessageBox.Show("File berhasil dibaca"); }

}

(4)

// Untuk mengacak kunci beaufort void Btn_EnkBeauClick(object sender, EventArgs e) {

(5)

else{

cipher += txtPlaintext.Text[i]; }

}

txtHasilEnk_1.Text += cipher;

}

stopwatch.Stop();

runtime_beau = (int.Parse(stopwatch.Elapsed.ToString("fffffff"))/10000f).ToString(); }

// untuk mengacak kunci spritz

void BtnAcak2Click(object sender, EventArgs e) {

Random rnd = newRandom(); string kunci2="";

int r;

for(int i=0; i<txtHasilEnk_1.Text.Length; i++) {

r = rnd.Next(0,kar.Length); kunci2 += kar[r];

}

txtKunciSpritz.Text = kunci2; }

//untuk mencari bilangan GCD publicintGCD(int a, int b) {

while (a != 0 && b != 0) {

if (a > b) a %= b; else b %= a; }

if (a == 0) return b; else return a; }

int = w1;

(6)

// untuk enkripsi algoritma spritz (KSA) public void SetKey(string key)

{

S = newint[256];

int keyLength = key.Length;

if (keyLength < 1)

MessageBox.Show("Kunci tidak boleh kosong");

for (int i = 0; i <= 255; i++) S[i] = (byte)i;

int j = 0;

for (int i = 0; i <= 255; i++) {

j = (j + S[i] + key[i % keyLength]) % 256; int iTmp = S[i];

S[i] = S[j]; S[j] = iTmp;

}

// untuk enkripsi algoritma spritz (PRGA) void BtnEnkSpritzClick(object sender, EventArgs e)

{

var stopwatch1 = newStopwatch(); stopwatch1.Start();

string plain = txtHasilEnk_1.Text; SetKey(txtKunciSpritz.Text); int i = 0, k = 0;

int j = 0,w=0, z = 0; Ascii tbl = newAscii();

Random r = newRandom(); while(GCD(w,256)!=1) {

w = r.Next()%256; }

w1 = w;

// txtGCD.Text= w1.ToString();

string cipher = "";

for (int a = 0; a < plain.Length; a++) {

i = (i + w) % 256;

(7)

int iTmp = S[i]; S[i] = S[j]; S[j] = iTmp;

z = S[(j + S[(i + S[(z + k)%256])%256])%256];

cipher += tbl.getChar((tbl.getDesimal(plain[a]) ^ z)%256); }

txtHasilEnk_2.Text = cipher; stopwatch1.Stop();

runtime_spritz= (int.Parse(stopwatch1.Elapsed.ToString("fffffff"))/10000f).ToString() ; textBox7.Text= ((double.Parse(runtime_beau) + double.Parse(runtime_spritz))/2).ToString(); }

// untuk menyimpan hasil enkripsi void BtnSimpanClick(object sender, EventArgs e) {

SaveFileDialog simpan = newSaveFileDialog(); simpan.Filter = "Super Enkripsi(*.tia)|*.tia"; simpan.FileName = "*.tia";

if (simpan.ShowDialog() == DialogResult.OK) {

FileStream fstream=newFileStream(simpan.FileName,FileMode.OpenOrCreate); StreamWriter sw = newStreamWriter(fstream);

SeekOrigin seekorigin = newSeekOrigin(); sw.BaseStream.Seek(0, seekorigin); sw.WriteLine(txtHasilEnk_2.Text); sw.Flush();

sw.Close();

string filenamee=simpan.FileName.Substring 4) + ".key";

FileStream fstreamm=newFileStream(filenamee,FileMode.OpenOrCreate); StreamWriter sww = newStreamWriter(fstreamm);

SeekOrigin seekoriginn = newSeekOrigin(); sww.BaseStream.Seek(0, seekoriginn); sww.WriteLine(txtKunciBeau.Text); sww.WriteLine(txtKunciSpritz.Text); sww.WriteLine(w1.ToString()); sww.Flush();

sww.Close(); }

}

(8)

void BtnCari2Click(object sender, EventArgs e) {

OpenFileDialog open = newOpenFileDialog(); open.Filter = "Super Enkripsi FIle(*.tia)|*.tia"; if (open.ShowDialog() == DialogResult.OK) {

txtCari2.Text = open.FileName;

string namaa = open.FileName.Substring(0, open.FileName.Length- 4) + ".key"; FileStream fstreamm

= newFileStream(namaa, FileMode.Open,FileAccess.ReadWrite); StreamReader sreaderr = newStreamReader(fstreamm); sreaderr.BaseStream.Seek(0, SeekOrigin.Begin);

kuncibeau = sreaderr.ReadLine(); kuncispritz = sreaderr.ReadLine(); w2 = int.Parse(sreaderr.ReadLine()); string sementara;

sreaderr.Close();

string nama = open.FileName.Substring(0, open.FileName.Length); FileStream fstream

= newFileStream(nama, FileMode.Open,FileAccess.ReadWrite); StreamReader sreader = newStreamReader(fstream); sreader.BaseStream.Seek(0, SeekOrigin.Begin); hasil_enk = sreader.ReadLine();

sreader.Close(); }

}

//untuk membaca file hasil enkripsi void BtnBukaFile2Click(object sender, EventArgs e) {

try{

txtPlaintext2.Text = hasil_enk; txtKunciBeau2.Text = kuncibeau; txtKunciSpritz2.Text = kuncispritz; }

catch(Exception err){

MessageBox.Show(err.Message); }

finally{

MessageBox.Show("File berhasil dibaca"); }

(9)

// untuk dekripsi algoritma spritz void BtnDekSpritzClick(object sender, EventArgs e) {

SetKey(txtKunciSpritz2.Text); int i = 0, k = 0;

int j = 0, z = 0;

Ascii tbl = newAscii();

string plain ="";

for (int a = 0; a < txtPlaintext2.Text.Length; a++) {

i = (i + w2) % 256;

j = (k + S[(j + S[i])%256]) % 256; k = (k + i + S[j]) % 256;

int iTmp = S[i]; S[i] = S[j]; S[j] = iTmp;

z = S[(j + S[(i + S[(z + k)%256])%256])%256];

plain += tbl.getChar((tbl.getDesimal(txtPlaintext2.Text[a]) ^ z)%256); }

txtHasilDek1.Text = plain; }

//untuk dekripsi algoritma beaufort void BtnDekBeauClick(object sender, EventArgs e) {

string plain = ""; int k,c;

for(int i=0; i<txtHasilDek1.Text.Length; i++) {

if(kar.Contains(txtHasilDek1.Text[i])){

c = Array.IndexOf(kar, txtHasilDek1.Text[i]); k = Array.IndexOf(kar, txtKunciBeau2.Text[i]); if(k-c<0)

plain += kar[(k-c+kar.Length)%kar.Length]; else

plain += kar[(k-c)%kar.Length]; }

else{

plain += txtHasilDek1.Text[i]; }

(10)

// untuk mereset halaman enkripsi

void BtnResetClick(object sender, EventArgs e) {

txtCari.Text=""; txtPlaintext.Text=""; txtHitung.Text=""; txtKunciBeau.Text=""; txtKunciSpritz.Text=""; txtHasilEnk_1.Text=""; txtHasilEnk_2.Text=""; textBox7.Text=""; runtime_baca.Text= ""; }

// untuk mereset halaman dekripsi

void Btn_Reset2Click(object sender, EventArgs e) {

txtCari2.Text= ""; txtHasilDek1.Text = ""; txtHasilDek2.Text = ""; txtKunciBeau2.Text = ""; txtKunciSpritz2.Text = ""; txtHitung2.Text = ""; txtPlaintext2.Text = ""; run_time_dek.Text = "";

}

c.

Source Code Ascii.cs

using System;

using System.Drawing;

using System.Windows.Forms;

namespace skripsi_tia {

public partial class Ascii:Form {

char[] tabel

= {'Ā','ā','Ă','ă','Ą','ą','Ć','ć','Ĉ','ĉ','Ċ','ċ','Č','į','İ','ı','IJ','ij','Ĵ','Ķ','ķ','ĸ','Ĺ','ĺ','Ļ','ļ','Ľ','ľ','Ŀ','ŀ','Ł','ł',

'','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';', '<','=','>','?',@','A','B','C','D','E','F','G','H','I','J','K','L',' M','N','O','P','Q','R','S','T','U','V','W','X','Y', 'Z','[','\\',']','^','_','`','a','b','c','d','e','f','g','h','i','j','k','l' ,'m','n','o','p','q','r','s','t','u','v','w', 'x','y','z','{','|','}','~','Ɗ','Ď','ď','Đ','đ','Ē','ē','Ĕ','ĕ','Ė','ė','Ę','ę','

Ě','ě','Ĝ','ĝ','Ğ','ğ','Ġ','ġ','Ģ','ģ', 'Ĥ','ĥ','Ħ','ħ','Ĩ','ĩ','Ī','ī','Ĭ','ĭ','Į','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','

(11)

publicintgetDesimal(char x) {

for (int i= 0; i < 256; i++) {

if (x.Equals(tabel[i])) return i;

}

return 0; }

publicchargetChar(int x) {

return tabel[x]; }

(12)

CURRICULUM VITAE

DATA DIRI

Nama

: Tia Rahmadianti

Tempat/Tanggal Lahir : Pangkalan Brandan/29 Januari 1996

Alamat : Jln Tj Pura no 37 Pelawi Pangkalan

Brandan, 20857

Agama : Islam

Jenis Kelamin

: Perempuan

Nomor Hp

: 081295568832

Email

: tiarahmadianti@gmail.com

RIWAYAT PENDIDIKAN

UNIVERSITAS

Universitas Sumatera Utara, Medan

2013

SMA

SMA DHARMA PATRA PANGKALAN BRANDAN

2010-2013

SMP

SMP DHARMA PATRA PANGKALAN BRANDAN

2007-2010

SD

SD DHARMA PATRA PANGKALAN BRANDAN

2001-2007

Bahasa Pemrograman

: Java, C++, PHP, HTML

Database

: MySQL

Software

: Office Application

(13)

SEMINAR/WORKSHOP/PELATIHAN

No Nama Kegiatan Jenis Kegiatan Tahun

1 Pelatihan Dasar Organisasi Pelatihan 2014

2 Training Islam Ceria Kreatif

(TRICK) Pelatihan 2014

3 Seminar Nasional Literasi

Informasi (SENARAI) Seminar 2014

4 What Will You be? Seminar 2013

5 Seminar Gelora Literasi

Teknologi Informasi & Komunikasi (Si GELITIK)

Seminar 2013

6 Effective Market

Segmentation and Targeting Seminar 2014

7 Global Inspiring Seminar of

Indonesia Next Program 2016 Seminar 2016

8 GIT Repository Workshop 2017

9 Industri Kreatif Seminar 2017

PENGALAMAN ORGANISASI

No Nama Organisasi Posisi Tahun

1 OSIS Bendahara 2 2011-2012

2 UKMI Al-Khuwarizmi Anggota Akademik dan

Kompetensi

2014-2015

3 UKMI Al-Khuwarizmi Sekretaris Bidang Akademik

dan Kompetensi

2015-2016

Referensi

Dokumen terkait

Namun penggunaan kriptografi klasik dengan kombinasi dua algoritma atau lebih masih digunakan oleh sebagian orang karena keserhanaan implementasi dan keamanan yang

Gambar 3.15 Perancangan Interface Halaman Tentang Aplikasi 38 Gambar 3.16 Perancangan Interface Halaman Tentang Algoritma 39 Gambar 3.17 Perancangan Interface Halaman Enkripsi

Algoritma modern yang digunakan adalah algoritma RC4 + Cipher , dimana algoritma tersebut merupakan salah satu jenis dari algoritma RC4 Cipher.RC4 + Cipher adalahsalah

Teknik transposisi menggunakan permutasi karakter, yang mana dengan menggunakan teknik ini pesan yang asli tidak dapat dibaca kecuali orang yang memiliki kunci untuk

RC4 + Cipher yang digunakan pada proses enkripsi, kolom C2 adalah hasil enkripsi kedua yang diperoleh dengan menggunakan algoritma RC4 + Cipher. Rata-rata yang diperoleh

Perancangan Aplikasi Pembelajaran Kriptografi Kunci Publik ElGamal Untuk Mahasiswa. Universitas

Document aDoc = wordApp.Documents.Open(ref filenameO, ref objFalse, ref objTrue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,

Substring (0, buka.FileName.Length); FileStream fstreamm = new FileStream (nama, FileMode.Open, FileAccess.ReadWrite);.. StreamReader sreader = new StreamReader (fstreamm);