• Tidak ada hasil yang ditemukan

BAB V PENUTUP

5.2. Saran

Saran yang dapat penulis berikan bagi peneliti selanjutnya adalah :

• Sistem ini masih jauh dari kesempurnaan dan masih memiliki banyak kekurangan. Oleh karena itu, sebaiknya bagi peneliti

69

selanjutnya dapat memperbaiki kekurangan dan meningkatkan kualitas sistem, diantaranya adalah:

• Sistem mampu menerima data input dari berbagai jenis file. • Data yang dipakai dalam jumlah besar dan bervariasi. • Pengujian dengan menggunakan metode Big-O tidak hanya

dilakukan secara visual dengan membandingkan waktu proses enkripsi dan dekripsi menggunakan grafik, tetapi juga dapat dilakukan dengan perhitungan matematis.

70

DAFTAR PUSTAKA

[1] Sadikin, Rifki. 2012. KRIPTOGRAFI UNTUK KEAMANAN JARINGAN [2] Rinaldi. 2007.

http://www.informatika.org/~rinaldi/Kriptografi/2007-2008/Makalah1/ MakalahIF5054-2007-A-051.pdf, [online], diakses pada tanggal 5 Mei 2015

[3] Fanani, Ikhsan. 2007. PENGGUNAAN BIG O NOTATION UNTUK MENGANALISA EFISIENSI ALGORITMA,

www.informatika.stei.itb.ac.id/~rinaldi.munir/Matdis/2006-2007/Makalah/ Makalah0607-129.pdf, [online], diakses pada tanggal 1 Juni 2015.

[4] Trisnawati. 2007. SISTEM KEAMANAN MENGGUNAKAN ALGORITMA BLOWFISH ADVANCE CS PADA FILE DAN FOLDER DATA,

www.unsri.ac.id/ upload/arsip/ Trisnawati 08053111015.doc, [online], diakses pada tanggal 4 April 2015

[5] Noname. 2002. BUKU AJAR NUMERIK, www.unsri.ac.id/upload/arsip/ ANALISIS% 20ALGORITMA.pdf, [online], diakses pada tanggal 1 Mei 2015 [6]Azizah Ulvah Nur. 2013. ANALISIS ALGORITMA. http://repository.upi.edu/ 2878/6/S_MTK_0900249_CHAPTER3.pdf, [online], diakses pada tanggal 2 Juni 2015

[7] Rowel, 2015. http://bigocheatsheet.com/, [online], diakses pada tanggal 17 Juli 2015

[8] Noname, 2002. http://science.slc.edu/~jmarshall/courses/2002/spring/cs50/ BigO/, [online], diakses pada tanggal 17 September 2015

[9] Noname, 2002. http://science.slc.edu/~jmarshall/courses/ 2002/spring/cs50/ BigO/. diakses pada tanggal 17 September 2015

71 LAMPIRAN I Stored Procedure

1. Stored Procedure BinaryReader • Listing : package blowfish; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException;

public class BinaryReader {

public String filename; public byte[] filebuffer; public int filesize;

public BinaryReader() { }

public BinaryReader(String filename) { this.filename = filename;

}

public void readFile() { this.Read();

}

public void readFile(String filename) { this.filename = filename;

this.Read(); }

private void Read() {

File file = new File(filename); filebuffer = new byte[(int) file.length()];

72

try {

FileInputStream inputStream = new FileInputStream(filename); int byteread = 0;

while ((byteread = inputStream.read(filebuffer)) != -1) { filesize += byteread;

}

inputStream.close();

System.out.println("Read " + filesize + " bytes"); } catch (FileNotFoundException ex) {

System.out.println("Unable to open file '" + filename + "'"); } catch (IOException ex) {

System.out.println("Error reading file '" + filename + "'"); }

} }

2. Stored Procedure BinaryWriter • Listing :

package blowfish;

import java.io.FileOutputStream; import java.io.IOException;

public class BinaryWriter {

public String filename; public byte[] filebuffer; public int filesize;

public BinaryWriter() { }

public BinaryWriter(String filename) { this.filename = filename;

}

public void writeFile() { this.write();

73

public void writeFile(String filename) { this.filename = filename;

this.write(); }

private void write() { try {

FileOutputStream outputStream = new FileOutputStream(filename); outputStream.write(filebuffer,0,filesize);

outputStream.close();

System.out.println("Wrote " + filebuffer.length + " bytes"); } catch (IOException ex) {

System.out.println("Error writing file '" + filename + "'"); }

} }

3. Stored Procedure Blowfish • Listing :

package blowfish;

import javax.crypto.Cipher;

import javax.crypto.spec.SecretKeySpec;

public class Blowfish {

public byte[] encrypt(byte[] byteText, byte[] key) throws Exception { System.out.println("Encrypting");

SecretKeySpec secretKeySpec = new SecretKeySpec(key, "Blowfish");

Cipher cipher = Cipher.getInstance("Blowfish"); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); byte[] encryptedByte = cipher.doFinal(byteText); return encryptedByte;

}

74

System.out.println("Decrypting");

SecretKeySpec secretKeySpec = new SecretKeySpec(key, "Blowfish");

Cipher cipher = Cipher.getInstance("Blowfish"); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);

// byte[] hasil = cipher.doFinal(new

BASE64Decoder().decodeBuffer(string));

byte[] decryptedByte = cipher.doFinal(byteText); return decryptedByte;

} }

4. Stored Procedure DisplayMain • Listing :

package blowfish;

import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell;

public class DisplayMain {

Display display; Shell shell;

InitHeader initHeader; InitFooter initFooter; InitPanel initPanel;

public DisplayMain(Display display, Shell shell) { this.display = display;

this.shell = shell;

shell.setLayout(new FormLayout());

initHeader = new InitHeader(display, shell); initHeader.Create();

75

initFooter = new InitFooter(display, shell); initFooter.Create();

initPanel = new InitPanel(display, shell); initPanel.Create(); shell.pack(); shell.setSize(1010, 620); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } }

5. Stored Procedure FormTest • Listing : package blowfish; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowData; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text;

76 Display display; Composite compositeParrent; Composite compositeForm; CLabel labelInfo; CLabel labelKey; CLabel labelSource; CLabel labelTarget; CLabel labelTime; Text textKey; Text textSource; Text textTarget; Text textInput; Text textOutput; Text textTime; Button buttonSource; Button buttonTarget; Button buttonEncrypt; Button buttonDecrypt;

public FormTest(Display display, Composite composite) { this.display = display;

this.compositeParrent = composite; }

public void Create() {

compositeForm = new Composite(compositeParrent, SWT.NONE); compositeForm.setLayout(new RowLayout(SWT.VERTICAL));

GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; gridLayout.marginHeight = 0; gridLayout.verticalSpacing = 2; gridLayout.marginWidth = 0; gridLayout.horizontalSpacing = 2; compositeForm.setLayout(gridLayout); CreateForm(); }

77

private void CreateForm() { int labelWidth = 100; int buttonWidth = 100; int textWidth = 770; int fullWidth = 870;

System.out.println("Creating test form");

labelKey = new CLabel(compositeForm, SWT.NONE); labelKey.setText("Kunci");

labelKey.setLayoutData(new GridData(labelWidth, 17));

textKey = new Text(compositeForm, SWT.BORDER); textKey.setLayoutData(new GridData(900, 17)); addSpanData(textKey, 2);

labelSource = new CLabel(compositeForm, SWT.NONE); labelSource.setText("File input");

labelSource.setLayoutData(new GridData(labelWidth, 17));

textSource = new Text(compositeForm, SWT.BORDER | SWT.READ_ONLY); textSource.setBackground(new Color(display.getCurrent(), 230, 230, 230)); textSource.setLayoutData(new GridData(textWidth, 17));

buttonSource = new Button(compositeForm, SWT.PUSH); buttonSource.setText("Buka");

buttonSource.setAlignment(SWT.CENTER);

buttonSource.setLayoutData(new GridData(buttonWidth, 21));

CLabel labelProcessspacer = new CLabel(compositeForm, SWT.NONE); labelProcessspacer.setText("");

Composite compositeRow1 = new Composite(compositeForm, SWT.NONE); compositeRow1.setLayout(new RowLayout(SWT.HORIZONTAL)); addSpanData(compositeRow1, 2);

RowData buttonRowdata = new RowData(); buttonRowdata.height = 21;

78

buttonEncrypt = new Button(compositeRow1, SWT.PUSH); buttonEncrypt.setText("Enkripsi");

buttonEncrypt.setAlignment(SWT.CENTER); buttonEncrypt.setLayoutData(buttonRowdata);

buttonDecrypt = new Button(compositeRow1, SWT.PUSH); buttonDecrypt.setText("Dekripsi");

buttonDecrypt.setAlignment(SWT.CENTER); buttonDecrypt.setLayoutData(buttonRowdata);

CLabel labelInput = new CLabel(compositeForm, SWT.NONE); labelInput.setText("Input");

Composite compositeRow2 = new Composite(compositeForm, SWT.NONE); compositeRow2.setLayout(new RowLayout(SWT.HORIZONTAL)); addSpanData(compositeRow2, 2);

RowData textareaRowdata = new RowData(); textareaRowdata.height = 150;

textareaRowdata.width = 855;

textInput = new Text(compositeRow2, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);

textInput.setBackground(new Color(display.getCurrent(), 230, 230, 230)); textInput.setLayoutData(textareaRowdata);

CLabel labelOutput = new CLabel(compositeForm, SWT.NONE); labelOutput.setText("Output");

Composite compositeRow3 = new Composite(compositeForm, SWT.NONE); compositeRow3.setLayout(new RowLayout(SWT.HORIZONTAL)); addSpanData(compositeRow3, 2);

textOutput = new Text(compositeRow3, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);

textOutput.setBackground(new Color(display.getCurrent(), 230, 230, 230)); textOutput.setLayoutData(textareaRowdata);

labelTarget = new CLabel(compositeForm, SWT.NONE); labelTarget.setText("File output");

79

textTarget = new Text(compositeForm, SWT.BORDER | SWT.READ_ONLY); textTarget.setBackground(new Color(display.getCurrent(), 230, 230, 230)); textTarget.setLayoutData(new GridData(textWidth, 17));

buttonTarget = new Button(compositeForm, SWT.PUSH); buttonTarget.setText("Simpan");

buttonTarget.setAlignment(SWT.CENTER);

buttonTarget.setLayoutData(new GridData(buttonWidth, 21));

labelTime = new CLabel(compositeForm, SWT.NONE); labelTime.setText("Waktu (ms)");

labelTime.setLayoutData(new GridData(labelWidth, 17));

textTime = new Text(compositeForm, SWT.BORDER | SWT.READ_ONLY); textTime.setBackground(new Color(display.getCurrent(), 230, 230, 230)); textTime.setLayoutData(new GridData(100, 17));

}

private static void addSpanData(CLabel comp, int span) {

GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); data.horizontalSpan = span;

comp.setLayoutData(data); }

private static void addSpanData(Text comp, int span) {

GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); data.horizontalSpan = span;

comp.setLayoutData(data); }

private static void addSpanData(Composite comp, int span) {

GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); data.horizontalSpan = span;

comp.setLayoutData(data); }

public void Hide() {

compositeForm.setVisible(false); }

80

public void Show() {

SpaceTab spaceTab = new SpaceTab(); compositeForm.setLocation(spaceTab.Get()); compositeForm.setVisible(true);

} }

6. Stored Procedure InitFooter • Listing : package blowfish; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell;

public class InitFooter { Display display; Shell shell; Composite composite; Composite containerFooter; FormData formData;

public InitFooter(Display display, Shell shell) {

this.display = display;

this.shell = shell; }

public void Create() {

81

formData = new FormData();

formData.left = new FormAttachment(0); formData.top = new FormAttachment(92); formData.width = 1010;

formData.height = 50;

containerFooter = new Composite(shell, SWT.NONE);

containerFooter.setBackground(new Color(display.getCurrent(), 32, 32, 32)); containerFooter.setLayoutData(formData);

GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; gridLayout.marginHeight = 0; gridLayout.verticalSpacing = 0; gridLayout.marginWidth = 0; gridLayout.horizontalSpacing = 0; gridLayout.marginTop=10; gridLayout.marginBottom=0; gridLayout.marginLeft=10; gridLayout.marginRight=10; containerFooter.setLayout(gridLayout);

CLabel labelCreator = new CLabel(containerFooter, SWT.NONE); labelCreator.setText("Oleh : Yohanes Catur Teguh Raharjo (085314081)");

labelCreator.setLayoutData(new GridData(900, 16));

labelCreator.setBackground(new Color(display.getCurrent(), 32, 32, 32)); labelCreator.setForeground(new Color(display.getCurrent(), 223, 223, 223));

CLabel labelUniversity = new CLabel(containerFooter, SWT.NONE);

labelUniversity.setText("Program Studi TI, Universitas Sanata Dharma, Yogyakarta, 2015"); labelUniversity.setLayoutData(new GridData(900, 16)); labelUniversity.setBackground(new Color(display.getCurrent(), 32, 32, 32)); labelUniversity.setForeground(new Color(display.getCurrent(), 223, 223, 223)); } }

82

7. Stored Procedure InitHeader • Listing : package blowfish; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell;

public class InitHeader {

Display display; Shell shell;

Composite composite;

Composite containerHeader; FormData formData;

public InitHeader(Display display, Shell shell) { this.display = display;

this.shell = shell; }

public void Create() {

System.out.println("Creating header container");

formData = new FormData();

formData.left = new FormAttachment(0); formData.top = new FormAttachment(0); formData.width = 1010;

83

containerHeader = new Composite(shell, SWT.NONE);

containerHeader.setBackground(new Color(display.getCurrent(), 32, 32, 32));

containerHeader.setLayoutData(formData);

GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; gridLayout.marginHeight = 0; gridLayout.verticalSpacing = 1; gridLayout.marginWidth = 0; gridLayout.horizontalSpacing = 1; gridLayout.marginTop = 10; gridLayout.marginBottom = 10; gridLayout.marginLeft = 10; gridLayout.marginRight = 10; containerHeader.setLayout(gridLayout);

CLabel labelApplication = new CLabel(containerHeader, SWT.NONE); labelApplication.setText("Aplikasi Enkripsi Dan Dekripsi ");

labelApplication.setLayoutData(new GridData(500, 26));

FontData[] fontApplication = labelApplication.getFont().getFontData(); fontApplication[0].setHeight(18);

labelApplication.setBackground(new Color(display.getCurrent(), 32, 32, 32)); labelApplication.setForeground(new Color(display.getCurrent(), 255, 255, 255)); labelApplication.setFont(new Font(containerHeader.getDisplay(), fontApplication));

CLabel labelAlgorithm = new CLabel(containerHeader, SWT.NONE); labelAlgorithm.setText("Menggunakan Algoritma Kriptografi Blowfish"); labelAlgorithm.setLayoutData(new GridData(500, 20));

FontData[] fontAlgorithm = labelAlgorithm.getFont().getFontData(); fontAlgorithm[0].setHeight(12);

labelAlgorithm.setBackground(new Color(display.getCurrent(), 32, 32, 32)); labelAlgorithm.setForeground(new Color(display.getCurrent(), 223, 223, 223)); labelAlgorithm.setFont(new Font(containerHeader.getDisplay(), fontAlgorithm));

}

84

8. Stored Procedure InitPanel • Listing : package blowfish; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell;

public class InitPanel { Display display; Shell shell; Composite composite; Composite containerTest; PanelTest panelTest;

public InitPanel(Display display, Shell shell) {

this.display = display; this.shell = shell; }

@SuppressWarnings("unused") public void Create()

{

System.out.println("Creating main container");

FormData formData = new FormData(); formData.left = new FormAttachment(0,8); formData.top = new FormAttachment(14); formData.width = 990;

formData.height = 535;

85

containerTest = new Composite(shell, SWT.NONE);

containerTest.setLayout(new RowLayout(SWT.VERTICAL)); containerTest.setLayoutData(formData);

panelTest = new PanelTest(display, shell, containerTest);

}

}

9. Stored Procedure Main • Listing :

package blowfish;

import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.*;

public class Main {

private static Display display; private static Shell shell;

public static void main(String[] args) {

System.out.println("Starting application"); System.out.println("");

display = new Display();

shell = new Shell(display, SWT.DIALOG_TRIM);

@SuppressWarnings("unused")

DisplayMain displayMain = new DisplayMain(display, shell); }

86

10. Stored Procedure PanelTest • Listing : package blowfish; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell;

public class PanelTest {

Display display; Shell shell; FormTest formTest; BinaryReader binaryReader; BinaryWriter binaryWriter; Blowfish blowFish; String textKey; byte[] byteKey; String textInput; byte[] byteInput; Integer lengthInput; String textOutput; byte[] byteOutput; Integer lengthOutput; String selectedInput; MessageBox messageBox;

public PanelTest(Display display, Shell shell, Composite composite) { this.display = display;

this.shell = shell;

this.blowFish = new Blowfish(); this.lengthInput = 0;

87

messageBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);

messageBox.setText("Kesalahan");

formTest = new FormTest(display, composite); formTest.Create();

formTest.buttonSource.addSelectionListener(new SelectionAdapter() {

@Override

public void widgetSelected(SelectionEvent e) { LoadSource(); } }); formTest.buttonTarget.addSelectionListener(new SelectionAdapter() { @Override

public void widgetSelected(SelectionEvent e) { SaveTarget(); } }); formTest.buttonEncrypt.addSelectionListener(new SelectionAdapter() { @Override

public void widgetSelected(SelectionEvent e) { Encrypt(); } }); formTest.buttonDecrypt.addSelectionListener(new SelectionAdapter() { @Override

public void widgetSelected(SelectionEvent e) { Decrypt();

} }); }

88

private void LoadSource() {

FileDialog filedialog = new FileDialog(shell, SWT.OPEN); filedialog.setText("File Input"); filedialog.setFilterPath(System.getProperty("user.dir") + "/input/"); String[] filterExtention = {"*.*"}; filedialog.setFilterExtensions(filterExtention); selectedInput = filedialog.open(); if (selectedInput != null) { formTest.textInput.setText(""); formTest.textOutput.setText(""); formTest.textSource.setText(selectedInput); binaryReader = new BinaryReader(selectedInput); binaryReader.readFile();

byteInput = new byte[binaryReader.filesize];

System.arraycopy(binaryReader.filebuffer, 0, byteInput, 0, binaryReader.filesize);

lengthInput = binaryReader.filesize; textInput = new String(byteInput);

formTest.textInput.setText(textInput); }

}

private void SaveTarget() {

FileDialog filedialog = new FileDialog(shell, SWT.SAVE); filedialog.setText("File Output");

filedialog.setFilterPath(System.getProperty("user.dir") + "/output/"); String[] filterExtention = {"*.*"};

filedialog.setFilterExtensions(filterExtention); String selectedFile = filedialog.open();

if (selectedFile != null) {

formTest.textTarget.setText(selectedFile); binaryWriter = new BinaryWriter(selectedFile); binaryWriter.filesize = binaryReader.filesize; binaryWriter.filebuffer = binaryReader.filebuffer; binaryWriter.writeFile(); formTest.textOutput.setText(new String(binaryWriter.filebuffer)); }

89

}

private void Encrypt() {

formTest.textOutput.setText(""); textKey = formTest.textKey.getText(); byteKey = textKey.getBytes(); if (textKey.length() > 0) { if (lengthInput > 0) { try { byteInput = textInput.getBytes(); Long startTime = System.currentTimeMillis(); byteOutput = blowFish.encrypt(byteInput, byteKey); Long estimatedTime = System.currentTimeMillis() - startTime; formTest.textTime.setText(estimatedTime.toString()); binaryWriter = new BinaryWriter(selectedInput + ".enc.txt"); binaryWriter.filesize = byteOutput.length; binaryWriter.filebuffer = byteOutput; binaryWriter.writeFile();

textOutput = new String(byteOutput);

formTest.textOutput.setText(textOutput);

} catch (Exception ex) { }

} else {

messageBox.setMessage("Teks input yang akan dienkripsi masih kosong. Silahkan buka file yang akan dienkripsi.");

messageBox.open(); }

} else {

messageBox.setMessage("Kunci masih kosong. Silahkan isi kunci yang akan digunakan.");

messageBox.open(); }

90

}

private void Decrypt() {

formTest.textOutput.setText(""); textKey = formTest.textKey.getText(); byteKey = textKey.getBytes(); if (textKey.length() > 0) { if (lengthInput > 0) { try { byteOutput = blowFish.decrypt(byteInput, byteKey); binaryWriter = new BinaryWriter(selectedInput + ".dec.txt"); binaryWriter.filesize = byteOutput.length; binaryWriter.filebuffer = byteOutput; binaryWriter.writeFile();

textOutput = new String(byteOutput);

formTest.textOutput.setText(textOutput);

} catch (Exception ex) {

System.out.println("Error");

} } else {

messageBox.setMessage("Teks input yang akan didekripsi masih kosong. Silahkan buka file yang akan didekripsi.");

messageBox.open(); }

} else {

messageBox.setMessage("Kunci masih kosong. Silahkan isi kunci yang akan digunakan.");

messageBox.open(); }

}

91

11. Stored Procedure SpaceTab • Listing :

package blowfish;

import org.eclipse.swt.graphics.Point;

public class SpaceTab {

public Point Get() {

return (new Point(10,40)); }

Dokumen terkait