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

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
{
public MainForm()
{

InitializeComponent();
//TODO: Add constructor code after the InitializeComponent() call.
}
void BtnMasukClick(object sender, EventArgs e)
{
Form1 a = new Form1();
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 = new OpenFileDialog();
dialog.Filter = "Document (MsWord)|*.doc| PDF|*.pdf";
dialog.Title = "Open File : ";

Universitas Sumatera Utara

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();
}
else if(metode=="pdf"){
reader = new PdfReader(dialog.FileName);
txtCari.Text = dialog.FileName;
}
}

}
// Untuk membuka file doc dan pdf
void BtnBukaFileClick(object sender, EventArgs e)
{
var stopwatch2 = new Stopwatch();
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();
runtime_baca.Text= (int.Parse(stopwatch2.Elapsed.ToString("fffffff"))/10000f).ToString();

Universitas Sumatera Utara

}
catch(Exception err){
MessageBox.Show(err.Message);
}
finally{
MessageBox.Show("File berhasil dibaca");
}
}
else{

var stopwatch3 = new Stopwatch();
stopwatch3.Start();
try{
int intPageNum = reader.NumberOfPages;
string[] words;
string line,text;
string temp="";
for (int i = 1; i