• Tidak ada hasil yang ditemukan

# Implementasi Kriptografi Algoritma Elgamal Dengan Kombinasi Steganografi Teknik End Of File (Eof) Untuk Keamanan File Text Dan File Citra

N/A
N/A
Protected

Membagikan "Implementasi Kriptografi Algoritma Elgamal Dengan Kombinasi Steganografi Teknik End Of File (Eof) Untuk Keamanan File Text Dan File Citra"

Copied!
31
0
0

Teks penuh

(1)

## 1. Form Utama

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.Numerics;

namespace TA_091401006_alespanjaitan {

public partial class Halaman_Utama : Form {

Pengaman aman = new Pengaman();

pengungkapan ungkap = new pengungkapan(); hitungmse mse = new hitungmse();

Bantuan fbantu = new Bantuan(); Tentang ftentang = new Tentang();

public Halaman_Utama() {

InitializeComponent(); }

private void Halaman_Utama_Load(object sender, EventArgs e) {

CenterToScreen(); char a;

int b = 169;

a = Convert.ToChar(b);

label1.Text = a.ToString() + " Ales Sanro Sotardodo Panjaitan";

}

private void button1_Click(object sender, EventArgs e) {

Application.Exit(); }

EventArgs e)

{

}

EventArgs e)

{

(2)

EventArgs e)

{

aman.ShowDialog(); }

private void gbr_pengamanan_Click(object sender, EventArgs e) {

aman.ShowDialog(); }

private void pengungkapanToolStripMenuItem_Click(object sender, EventArgs e)

{

ungkap.ShowDialog(); }

private void gbr_pengungkapan_Click(object sender, EventArgs e)

{

ungkap.ShowDialog(); }

private void tentangProgrammerToolStripMenuItem_Click(object sender, EventArgs e)

{

ftentang.ShowDialog(); }

private void

EventArgs e)

{

fbantu.ShowDialog(); }

private void pictureBox1_Click(object sender, EventArgs e) {

mse.ShowDialog(); }

EventArgs e)

{

mse.ShowDialog(); }

private void Halaman_Utama_FormClosed(object sender,

FormClosedEventArgs e)

{

Application.Exit(); }

}

(3)

## 2. Form Pengamanan (Embedding dan Enkripsi)

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 System.Numerics;

namespace TA_091401006_alespanjaitan {

public partial class Pengaman : Form {

endOfFile embd = new endOfFile();

prosesBilangan bilangan = new prosesBilangan(); elgamal enkripDekrip = new elgamal();

inputOutput io = new inputOutput();

string propgambar,propteks;

BigInteger sebelum=123, nilai_hitung_a;

public Pengaman() {

InitializeComponent(); }

private void Pengaman_Load(object sender, EventArgs e) {

CenterToScreen();

bt_embed.Enabled = bt_spData.Enabled = sp_sgimage.Enabled = bt_bgkt_g.Enabled = false;

bt_bilprim.Enabled = bt_enkripsi.Enabled = bt_htgk.Enabled = bt_htgy.Enabled = false;

bt_nilaiy.Enabled = bt_spData.Enabled = bk_teks.Enabled = false;

gbr_asli.Image = gb_sgimage.Image = gb_cpimage.Image = null;

propCA.Text = propText.Text = "";

teks_asli.Text = bilprima.Text = nilg.Text = nilk.Text = nilx.Text = nily.Text = "";

}

private void bk_gbr_asli_Click(object sender, EventArgs e) {

try {

Cursor.Current = Cursors.Default;

gbr_asli.Image = io.bukagbr("Format Bitmap (*.bmp)|*.bmp|Format JPEG(*.jpg)|*.jpg"); if (gbr_asli.Image != null)

{

(4)

+ " Piksel\nTinggi : " +

gbr_asli.Image.Height.ToString() + " Piksel\n\n"; propCA.Text = propgambar;

bk_teks.Enabled = true; }

if (teks_asli.Text != "") bk_teks.Enabled = true; }

catch (Exception ex) {

}

finally {

Cursor.Current = Cursors.WaitCursor; }

}

private void bk_gbr_sgimage_Click(object sender, EventArgs e) {

try {

Cursor.Current = Cursors.WaitCursor;

gb_sgimage.Image = io.bukagbr("Format Bitmap (*.bmp)|*.bmp");

if (gb_sgimage.Image != null) {

bt_bilprim.Enabled = true; propCS.Text = "Lebar : " +

gb_sgimage.Image.Width.ToString() + " Piksel\nTinggi : " +

gb_sgimage.Image.Height.ToString() + " Piksel"; }

}

catch (Exception ex) {

}

finally {

Cursor.Current = Cursors.Default; }

}

private void bk_teks_Click(object sender, EventArgs e) {

try {

teks_asli.Text = io.bukateks(); if (teks_asli.Text != "")

{

bt_embed.Enabled = true;

propText.Text = "Panjang : " +

teks_asli.TextLength.ToString() + " Karakter"; }

(5)

catch (Exception ex) {

}

}

private void sp_sgimage_Click(object sender, EventArgs e) {

try {

if (io.spGambar(gb_sgimage.Image))

pesanInformasi("Gambar berhasil di simpan"); }

catch (Exception ex) {

}

}

private void bt_embed_Click(object sender, EventArgs e) {

try {

Cursor.Current = Cursors.WaitCursor;

DateTime awal, akhir; string selisih;

awal = DateTime.Now;

Bitmap gbasli = new Bitmap(gbr_asli.Image); Bitmap sg = new Bitmap(embd.embed(gbasli,

teks_asli)); gb_sgimage.Image = sg;

propCS.Text = "Lebar : " + sg.Width.ToString()

+ " Piksel\nTinggi : " + sg.Height.ToString() + " Piksel";

sp_sgimage.Enabled = true; bt_bilprim.Enabled = true; akhir = DateTime.Now; selisih =

akhir.Subtract(awal).TotalMilliseconds.ToString() ;

pesanInformasi("Lama Embed : " + selisih + " Milliseconds");

}

catch (Exception ex) {

}

finally {

Cursor.Current = Cursors.Default; }

(6)

private void bt_enkripsi_Click(object sender, EventArgs e) {

try {

BigInteger p, g, x, y, k;

Cursor.Current = Cursors.WaitCursor; DateTime awal, akhir;

awal = DateTime.Now;

p = BigInteger.Parse(bilprima.Text); g = BigInteger.Parse(nilg.Text); x = BigInteger.Parse(nilx.Text); y = BigInteger.Parse(nily.Text); k = BigInteger.Parse(nilk.Text);

nilai_hitung_a = bilangan.moduloexponensial(g, k, p); gb_cpimage.Image =

enkripDekrip.enkripsi((Bitmap)gb_sgimage.Image,p,y ,k);

bt_spData.Enabled = true; akhir = DateTime.Now; string selisih =

akhir.Subtract(awal).TotalMilliseconds.ToString();

propCC.Text = "\nLebar : " +

gb_cpimage.Image.Width.ToString() + " Piksel\nTinggi : " +

gb_cpimage.Image.Height.ToString() + " Piksel"; pesanInformasi("Lama Enkripsi : " + selisih); }

catch (Exception ex) {

}

finally {

Cursor.Current = Cursors.Default; }

}

private void bt_htgy_Click(object sender, EventArgs e) {

try {

BigInteger prim, g, x;

prim = BigInteger.Parse(bilprima.Text); g = BigInteger.Parse(nilg.Text);

x = BigInteger.Parse(nilx.Text);

nily.Text = bilangan.moduloexponensial(g, x, prim).ToString();

bt_htgk.Enabled = true; }

catch (Exception ex) {

(7)

private void bt_bilprim_Click(object sender, EventArgs e) {

DateTime wkt1, wkt2; BigInteger bwh,atas;

try {

Cursor.Current = Cursors.WaitCursor; bwh = 3;

if (pilihbit.Text == "P <= 8-bit") {

atas = 255; }

else if (pilihbit.Text == "P <= 16-bit") {

atas = 65535; }

else if (pilihbit.Text == "P <= 24-bit") {

atas = 16777215; }

else if (pilihbit.Text == "P <= 32-bit") {

atas = 4294967295; }

else if (pilihbit.Text == "P <= 64-bit") {

atas = 18446744073709551615; }

else if (pilihbit.Text == "P <= 128-bit") {

atas =

BigInteger.Parse("3402823669209384634633746074317682

11455"); }

else if (pilihbit.Text == "P <= 256-bit") {

atas =

BigInteger.Parse("1157920892373161954235709850086879

07853269984665640564039457584007913129639935"); }

else if (pilihbit.Text == "P <= 512-bit"){ atas =

BigInteger.Parse("1340780792994259709957402499820584

6127479365820592393377723561443721764030073546976801 8742981669034276900318581864860508537538828119465699 46433649006084096");

}

else if (pilihbit.Text == "P <= 1-Mb") {

atas =

BigInteger.Parse("1797693134862315907729305190789024

7336179769789423065727343008115773267580550096313270 8477322407536021120113879871393357658789768814416622 4928474306394741243777678934248654852763022196012460 9411945308295208500576883815068234246288147391311054 0827237163350510684586298239947245938479716304835356 329624224137216");

(8)

else {

atas = 65535; }

wkt1 = DateTime.Now; bilprima.Text =

bilangan.bangkitprima(bwh,atas).ToString(); bt_bgkt_g.Enabled = true;

wkt2 = DateTime.Now;

string lamaeksekusi =

wkt2.Subtract(wkt1).TotalMilliseconds.ToString(); pesanInformasi("Bilangan prima menggunakan

"+(bilangan.ceksuku(BigInteger.Parse(bilprima.Text))

*8).ToString()+"\n"+lamaeksekusi+ "Milliseconds"); }

catch (Exception ex) {

}

finally {

Cursor.Current = Cursors.Default; }

}

private void bt_spData_Click(object sender, EventArgs e) {

try {

Cursor.Current = Cursors.WaitCursor;

if (io.spData(gb_cpimage.Image, bilprima.Text, nilx.Text, nilai_hitung_a.ToString()))

pesanInformasi("Gambar dan Kunci berhasil di simpan");

}

catch (Exception ex) {

}

finally {

Cursor.Current = Cursors.Default; }

}

private void bt_bgkt_gx_Click(object sender, EventArgs e) {

try {

BigInteger zi;

if (nilg.Text == "") {

(9)

} else {

zi = BigInteger.Parse(nilg.Text); }

nilg.Text = bilangan.acak(997, zi,

BigInteger.Parse(bilprima.Text)).ToString();

bt_nilaiy.Enabled = true; }

catch (Exception ex) {

} }

private void bt_nilaiy_Click(object sender, EventArgs e) {

try {

BigInteger zi;

if (nilx.Text == "") {

zi = 1; }

else {

zi = BigInteger.Parse(nilx.Text); }

nilx.Text = bilangan.acak(997, zi,

BigInteger.Parse(bilprima.Text)).ToString();

bt_htgy.Enabled = true; }

catch (Exception ex) {

} }

private void bt_htgk_Click(object sender, EventArgs e) {

try {

BigInteger p,zi;

if (nilk.Text == "") {

zi = 1; }

else {

zi = BigInteger.Parse(nilk.Text); }

p = BigInteger.Parse(bilprima.Text); zi = bilangan.acak(997, zi, p);

while (!(BigInteger.GreatestCommonDivisor(p, zi)==1)) {

(10)

nilk.Text = zi.ToString(); bt_enkripsi.Enabled = true; }

catch (Exception ex) {

} }

private void teks_asli_Leave(object sender, EventArgs e) {

if (teks_asli.Text == "" || gbr_asli.Image == null) bt_embed.Enabled = false;

else

bt_embed.Enabled = true; if (teks_asli.Text != "") {

bt_embed.Enabled = true; propteks = "Panjang : " +

teks_asli.TextLength.ToString() + " Karakter"; propText.Text = propteks;

} }

private void check_Click(object sender, EventArgs e) {

try {

Bitmap gbr = new Bitmap(gbr_asli.Image); Cursor.Current = Cursors.WaitCursor; if (embd.checkgbr(gbr))

propCA.Text = propgambar + "Tidak ada kunci"; else

propCA.Text = propgambar + "Ada kunci"; if (embd.checktext(teks_asli))

propText.Text = propteks + "\nTidak ada kunci"; else

propText.Text = propteks + "\nAda kunci"; }

catch (Exception a) {

}

finally {

Cursor.Current = Cursors.Default; }

}

void pesanInformasi(string pesan) {

MessageBox.Show(pesan, "Informasi", MessageBoxButtons.OK,

MessageBoxIcon.Information,

MessageBoxDefaultButton.Button1);

}

(11)

MessageBox.Show(pesan, "Kesalahan", MessageBoxButtons.OK,

MessageBoxIcon.Warning,

MessageBoxDefaultButton.Button1);

}

private void Pengaman_FormClosed(object sender,

FormClosedEventArgs e)

{ }

} }

## 3. Form Pengungkapan (Ekstraksi dan Dekripsi)

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 System.Numerics;

namespace TA_091401006_alespanjaitan {

public partial class pengungkapan : Form {

prosesBilangan bilangan = new prosesBilangan(); elgamal enkripDekrip = new elgamal();

endOfFile embedEkstrak = new endOfFile(); inputOutput io = new inputOutput();

public pengungkapan() {

InitializeComponent(); }

private void pengungkapan_Load(object sender, EventArgs e) {

CenterToScreen(); gbr_asli.Image = null; gbr_sgimage.Image = null; gbr_asli.Image = null; gb_hasil.Image = null; teks_asli.Text = ""; nilp.Text = ""; nila.Text = ""; nilx.Text = "";

bt_dekripsi.Enabled = false; bt_ekstrak.Enabled = false;

bt_simpangbr_sgimage.Enabled = false; bk_teks.Enabled = false;

(12)

}

private void bk_cpimage_Click(object sender, EventArgs e) {

try {

gbr_asli.Image = io.bukagbr("Format Bitmap (*.bmp)|*.bmp");

if (gbr_asli.Image != null) {

propCA.Text = "\nLebar : " +

gbr_asli.Image.Width + "Piksel\nTinggi : " + gbr_asli.Image.Height + " Piksel";

bt_bukakunci.Enabled = true; }

} catch {

}

private void bt_bukagbr_Click(object sender, EventArgs e) {

gbr_sgimage.Image = io.bukagbr("Format Bitmap (*.bmp)|*.bmp");

if (gbr_sgimage.Image != null) {

bt_bukakunci.Enabled = true; bt_ekstrak.Enabled = true; }

}

private void bk_teks_Click(object sender, EventArgs e) {

SaveFileDialog simpan = new SaveFileDialog();

simpan.Filter = "Format Bitmap (*.bmp)|*.bmp|Format JPEG(*.jpg)|*.jpg";

if (gb_hasil.Image != null) {

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

RichTextBox sementara = new RichTextBox(); sementara.Text = "";

FileStream teks = new FileStream(simpan.FileName + ".txt", FileMode.CreateNew,

FileAccess.Write);

StreamWriter tulis = new StreamWriter(teks); for (int i = 0; i < teks_asli.TextLength; i++) {

sementara.Text += teks_asli.Text[i]; if (teks_asli.Text[i] == 13 |

teks_asli.TextLength == (i + 1)) tulis.WriteLine(teks_asli.Text); }

tulis.Close(); teks.Close();

(13)

pesanInformasi("Gambar dan pesan berhasil di simpan");

} } else {

pesanKesalahan("Gambar Kosong"); }

}

private void bt_simpangbr_sgimage_Click(object sender,

EventArgs e)

{

if (gbr_sgimage.Image != null) {

if (io.spGambar(gbr_sgimage.Image))

pesanInformasi("Gambar berhasil di simpan"); }

else {

pesanKesalahan("Gambar masih kosong..."); }

}

private void bt_dekripsi_Click(object sender, EventArgs e) {

try {

Cursor.Current = Cursors.WaitCursor; DateTime awal, akhir;

awal = DateTime.Now; gbr_sgimage.Image =

enkripDekrip.dekripsi((Bitmap)(gbr_asli.Image),

BigInteger.Parse(nilp.Text),

BigInteger.Parse(nilx.Text),

BigInteger.Parse(nila.Text));

akhir = DateTime.Now; string selisih =

akhir.Subtract(awal).TotalMilliseconds.ToString(); propSC.Text = "\nTinggi : " +

gbr_sgimage.Image.Height.ToString() + " Piksel\nLebar : " +

gbr_sgimage.Image.Width.ToString() + " Piksel"; bt_simpangbr_sgimage.Enabled = true;

bt_ekstrak.Enabled = true;

pesanInformasi("Lama dekripsi " + selisih + " Millisecond");

}

catch (Exception ex) {

pesanKesalahan("Silahkan periksa semua keabsahan informasi anda\n* Terjadi Kesalah pada \n- " + ex.ToString());

}

finally {

Cursor.Current = Cursors.WaitCursor; }

(14)

private void bt_ekstrak_Click(object sender, EventArgs e) {

DateTime awal = DateTime.Now, akhir;

try {

Cursor.Current = Cursors.WaitCursor;

Bitmap gbrstego = new Bitmap(gbr_sgimage.Image); int status = embedEkstrak.cekposisi(gbrstego); if (status != 0)

{

gb_hasil.Image = embedEkstrak.pisahgbr(gbrstego, status);

teks_asli.Text = embedEkstrak.pisahteks(gbrstego, status).Text;

propHasil.Text = "\nLebar : " + gb_hasil.Image.Width.ToString() + " Piksel\nTinggi : "

+ gb_hasil.Image.Height.ToString() + " Piksel\n\nPanjang : " +

teks_asli.TextLength.ToString() + " Karakter"; bk_teks.Enabled = true;

} else {

pesanKesalahan("Maaf, Tidak menemukan teks dalam Citra");

} } catch {

finally {

Cursor.Current = Cursors.Default; akhir = DateTime.Now;

pesanInformasi("Lama Ekstrak : " +

akhir.Subtract(awal).TotalMilliseconds.ToString() + " Milliseconds");

} }

private void bt_bukakunci_Click(object sender, EventArgs e) {

try {

OpenFileDialog bukatxt = new OpenFileDialog(); bukatxt.Filter = "File Text (*.txt)|*.txt"; if (DialogResult.OK == bukatxt.ShowDialog()) {

string bacaloh = "";

{

(15)

nilp.Text = ceknilai(bacaloh); }

if (cekstring(bacaloh) == "NILAIA") {

nila.Text = ceknilai(bacaloh); }

if (cekstring(bacaloh) == "NILAIX") {

nilx.Text = ceknilai(bacaloh); }

label4.Text = "Kunci menggunakan : " +

(bilangan.ceksuku(BigInteger.Parse(nilp.Text)) * 8).ToString() + " - bit";

bt_dekripsi.Enabled = true; }

} catch {

}

public string cekstring(string kiriman) {

string maukirim = "";

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

if (kiriman[i] != ' ') {

maukirim = maukirim + kiriman[i]; }

else {

break; }

}

return maukirim; }

public string ceknilai(string kiriman) {

string maukirim = "";

for (int i = kiriman.Length - 1; i >= 0; i--) {

if (kiriman[i] != ' ' & kiriman[i] >= '0' & kiriman[i] <= '9')

{

maukirim = kiriman[i] + maukirim; }

else {

break; }

(16)

return maukirim; }

void pesanInformasi(string pesan) {

MessageBox.Show(pesan, "Informasi", MessageBoxButtons.OK,

MessageBoxIcon.Information,

MessageBoxDefaultButton.Button1);

}

void pesanKesalahan(string pesan) {

MessageBox.Show(pesan, "Kesalahan", MessageBoxButtons.OK,

MessageBoxIcon.Warning,

MessageBoxDefaultButton.Button1);

}

private void pengungkapan_FormClosed(object sender,

FormClosedEventArgs e)

{ } } }

## 4. Form Hitung Mean Squared Error (MSE)

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.Drawing.Imaging; using System.Threading;

namespace TA_091401006_alespanjaitan {

public partial class hitungmse : Form {

hitungMseClass mse = new hitungMseClass(); public hitungmse()

{

InitializeComponent(); }

private void hitungmse_Load(object sender, EventArgs e) {

CenterToParent(); }

private void bt_bukagbr1_Click(object sender, EventArgs e) {

(17)

bukagbr.InitialDirectory = "";

bukagbr.Filter = "Format Bitmap (*.bmp)|*.bmp|Format JPEG(*.jpg)|*.jpg";

bukagbr.FilterIndex = 1;

bukagbr.RestoreDirectory = true;

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

Bitmap gb = new Bitmap(bukagbr.FileName); gbr1.Image = gb;

label3.Text = perolehnama(bukagbr.FileName)+ "\n" + gb.Size.Width+ "\n" + gb.Size.Height;

} }

private void bt_bukagbr2_Click(object sender, EventArgs e) {

OpenFileDialog bukagbr = new OpenFileDialog(); bukagbr.InitialDirectory = "";

bukagbr.Filter = "Format Bitmap (*.bmp)|*.bmp|Format JPEG(*.jpg)|*.jpg";

bukagbr.FilterIndex = 1;

bukagbr.RestoreDirectory = true;

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

Bitmap gb = new Bitmap(bukagbr.FileName); gbr2.Image = gb;

label6.Text = perolehnama(bukagbr.FileName) + "\n" + gb.Size.Width + "\n" + gb.Size.Height;

} }

private void button1_Click(object sender, EventArgs e) {

try {

Cursor.Current = Cursors.WaitCursor; Bitmap datagb1 = new Bitmap(gbr1.Image); Bitmap datagb2 = new Bitmap(gbr2.Image);

if (datagb1.Width == datagb2.Width & datagb1.Height == datagb2.Height)

{

label7.Text = mse.hitung(datagb1, datagb2).ToString();

MessageBox.Show("Compare Selesai", "Informasi",

MessageBoxButtons.OK, MessageBoxIcon.Information,

MessageBoxDefaultButton.Button1);

} else {

MessageBox.Show("Pastikan resolusi gambar anda sama!", "Informasi", MessageBoxButtons.OK,

MessageBoxIcon.Information,

MessageBoxDefaultButton.Button1);

} } catch {

(18)

}

finally {

Cursor.Current = Cursors.Default; }

}

string perolehnama(string param) {

string temp; temp = "";

for (int i = param.Length-1; i >= 0; i--) {

if (param[i] != 92) {

temp = param[i] + temp; }

else {

break; }

}

return (temp); }

private void gbr2_Click(object sender, EventArgs e) {

} } }

## 5. Form Menggunakan Aplikasi

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;

namespace TA_091401006_alespanjaitan {

public partial class Bantuan : Form {

inputOutput io = new inputOutput(); public Bantuan()

{

(19)

private void Bantuan_Load(object sender, EventArgs e) {

CenterToScreen(); }

private void comboBox1_SelectedIndexChanged(object sender,

EventArgs e)

{

string dir = "D:/Aplikasi Tugas

Akhir/TA_091401006_alespanjaitan/TA_091401006_alespa njaitan/";

if (comboBox1.Text == "Pengamanan") {

richTextBox1.Text =

io.bacateks_dir(dir+"Bantuan/Pengamanan.ales").Text; }

if (comboBox1.Text == "Pengungkapan") {

richTextBox1.Text = io.bacateks_dir(dir + "Bantuan/Pengungkapan.ales").Text;

}

if (comboBox1.Text == "Hitung MSE") {

richTextBox1.Text = io.bacateks_dir(dir + "Bantuan/Hitung MSE.ales").Text;

} }

} }

## 6. Form Tentang

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;

namespace TA_091401006_alespanjaitan {

public partial class Tentang : Form {

inputOutput io = new inputOutput(); public Tentang()

{

InitializeComponent(); }

private void Tentang_Load(object sender, EventArgs e) {

(20)

}

private void comboBox1_SelectedIndexChanged(object sender,

EventArgs e)

{

string dir = "D:/Aplikasi Tugas

Akhir/TA_091401006_alespanjaitan/TA_091401006_al espanjaitan/Tentang/";

try {

if (comboBox1.Text == "Programmer") {

pictureBox1.ImageLocation = dir+"Programmer.jpg"; richTextBox1.Text = io.bacateks_dir(dir +

"Programmer.ales").Text; }

else if (comboBox1.Text == "Parents") {

pictureBox1.ImageLocation = dir + "parent.jpg"; richTextBox1.Text = io.bacateks_dir(dir +

"parent.ales").Text; }

else if (comboBox1.Text == "Family") {

pictureBox1.ImageLocation = dir+"Keluarga.jpg"; richTextBox1.Text = io.bacateks_dir(dir +

"Keluarga.ales").Text; }

else {

pictureBox1.Image = null; richTextBox1=null;

} } catch {

}

private void Tentang_FormClosed(object sender,

FormClosedEventArgs e)

{

} } }

## 7. Class ElGamal

using System;

using System.Collections.Generic; using System.Linq;

using System.Text; using System.Numerics; using System.Drawing;

(21)

{

class elgamal {

prosesBilangan bilangan = new prosesBilangan();

public Bitmap dekripsi(Bitmap gb1, BigInteger p, BigInteger

x, BigInteger a)

{

int x_asal, t, l; t = gb1.Height; l = gb1.Width; UInt16 nsuku;

BigInteger a_invers = bilangan.moduloexponensial(a, (p - 1 - x), p);

nsuku = bilangan.ceksuku(p);

Bitmap hasil = new Bitmap((l / nsuku), t); BigInteger r1, g1, b1;

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

x_asal = 0;

for (int j = 0; j < hasil.Width; j++) {

r1 = g1 = b1 = 0;

for (int ii = 0; ii < nsuku; ii++) {

r1 += BigInteger.Pow(256, ii) * gb1.GetPixel(x_asal, i).R; g1 += BigInteger.Pow(256, ii) *

gb1.GetPixel(x_asal, i).G; b1 += BigInteger.Pow(256, ii) *

gb1.GetPixel(x_asal, i).B; x_asal += 1;

}

hasil.SetPixel(j, i, Color.FromArgb(255, (byte)((r1 * a_invers) % p), (byte)((g1 * a_invers) % p), (byte)((b1 * a_invers) % p))); }

}

return hasil; }

public Bitmap enkripsi(Bitmap asal, BigInteger p, BigInteger

y, BigInteger k)

{

BigInteger temp,cr,cg,cb;

Int32 x1, y1, el_r, el_g, el_b; x1 = asal.Width;

y1 = asal.Height;

UInt16 nsuku;

nsuku = bilangan.ceksuku(p);

Bitmap hasil = new Bitmap((x1 * nsuku), y1); temp = bilangan.moduloexponensial(y, k, p); int x_hasil;

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

x_hasil = 0;

(22)

el_r = asal.GetPixel(j, i).R; el_g = asal.GetPixel(j, i).G; el_b = asal.GetPixel(j, i).B;

cr = (temp * (el_r % p)) % p; cg = (temp * (el_g % p)) % p; cb = (temp * (el_b % p)) % p;

for (int ii = 0; ii < nsuku; ii++) {

hasil.SetPixel(x_hasil, i,

Color.FromArgb(255, (Byte)(cr % 256),

(Byte)(cg % 256), (Byte)(cb % 256))); cr /= 256; cg /= 256; cb /= 256;

x_hasil += 1; }

} }

return hasil; }

} }

## 8. Class End Of File

using System;

using System.Collections.Generic; using System.Linq;

using System.Text; using System.Drawing;

using System.Windows.Forms;

namespace TA_091401006_alespanjaitan {

class endOfFile {

public int cekposisi(Bitmap gbrstego) {

string tanda = "";

for (int i = 0; i < gbrstego.Height; i++) {

tanda += Convert.ToChar(gbrstego.GetPixel(0, i).R); tanda += Convert.ToChar(gbrstego.GetPixel(0, i).G); tanda += Convert.ToChar(gbrstego.GetPixel(0, i).B); tanda += Convert.ToChar(gbrstego.GetPixel(1, i).R); tanda += Convert.ToChar(gbrstego.GetPixel(1, i).G); tanda += Convert.ToChar(gbrstego.GetPixel(1, i).B); tanda += Convert.ToChar(gbrstego.GetPixel(2, i).R); tanda += Convert.ToChar(gbrstego.GetPixel(2, i).G); if (tanda == "**ALES**")

{

return i; }

tanda = ""; }

return 0; }

(23)

{

byte r, g, b;

RichTextBox teksasli = new RichTextBox(); RichTextBox teksasli2 = new RichTextBox();

Bitmap hasil = new Bitmap(gbrstego.Width, posisi); for (int i = 0; i < posisi; i++)

{

for (int j = 0; j < hasil.Width; j++) {

r = gbrstego.GetPixel(j, i).R; g = gbrstego.GetPixel(j, i).G; b = gbrstego.GetPixel(j, i).B;

hasil.SetPixel(j, i, Color.FromArgb(255, r, g, b));

} }

return hasil; }

public RichTextBox pisahteks(Bitmap gbrstego, int posisi) {

string banding = " "; char sementar;

RichTextBox teksasli = new RichTextBox(); RichTextBox teksasli2 = new RichTextBox(); byte awl_akhr = 0;

for (int i = posisi; i < gbrstego.Height; i++) {

for (int j = 0; j < gbrstego.Width; j++) {

for (int wrn = 0; wrn < 3; wrn++) {

if (wrn == 0) {

sementar =

Convert.ToChar(gbrstego.GetPixel(j, i).R);

}

else if (wrn == 1) {

sementar =

Convert.ToChar(gbrstego.GetPixel(j, i).G);

} else {

sementar =

Convert.ToChar(gbrstego.GetPixel(j, i).B);

}

banding = tukarposisi(banding,sementar);

if (banding == "**ALES**") {

awl_akhr += 1; }

if (banding == "**ALES**" & awl_akhr == 2) {

for (int ii = 1; ii < teksasli.TextLength - 7; ii++)

{

(24)

return teksasli2; }

if (awl_akhr == 1) {

teksasli.Text += sementar; }

} } }

return teksasli2; }

public Bitmap embed(Bitmap gbasli, RichTextBox teks_asli) {

RichTextBox sementara = new RichTextBox(); Int32 l, t, temp, r1, g1, b1;

l = gbasli.Width; t = gbasli.Height;

sementara.Text = "**ALES**" + teks_asli.Text + "**ALES**";

temp = sementara.TextLength / (l * 3);

if (sementara.TextLength % (l * 3) != 0) temp++;

Bitmap hasil = new Bitmap(l, t + temp);

for (Int32 i = 0; i < l; i++) {

for (Int32 j = 0; j < t; j++) {

r1 = gbasli.GetPixel(i, j).R; g1 = gbasli.GetPixel(i, j).G; b1 = gbasli.GetPixel(i, j).B;

hasil.SetPixel(i, j, Color.FromArgb(255, r1, g1, b1));

} }

Int32 penanda = 0;

for (Int32 i = 0; i < temp; i++) {

for (Int32 k = 0; k < hasil.Width; k++) {

if (penanda >= sementara.TextLength) r1 = 0;

else {

r1 = sementara.Text[penanda]; penanda++;

}

if (penanda >= sementara.TextLength) g1 = 0;

else {

(25)

}

if (penanda >= sementara.TextLength) b1 = 0;

else {

b1 = sementara.Text[penanda]; penanda++;

}

hasil.SetPixel(k, (i+t), Color.FromArgb(255, r1, g1, b1));

if (penanda >= sementara.TextLength) {

break; }

}

if (penanda >= sementara.TextLength) {

break; }

}

return hasil; }

public bool checkgbr(Bitmap gbr) {

int x=gbr.Width, y=gbr.Height; string tanda = " "; char temp;

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

for (int j = 0; j < x; j++) {

temp = Convert.ToChar(gbr.GetPixel(j,i).R); tanda = tukarposisi(tanda, temp);

if (tanda == "**ALES**") {

MessageBox.Show("Citra anda mengandung kunci");

return false; }

temp = Convert.ToChar(gbr.GetPixel(j, i).G); tanda = tukarposisi(tanda, temp);

if (tanda == "**ALES**") {

MessageBox.Show("Citra anda mengandung kunci");

return false; }

temp = Convert.ToChar(gbr.GetPixel(j, i).B); tanda = tukarposisi(tanda, temp);

if (tanda == "**ALES**") {

MessageBox.Show("Citra anda mengandung kunci");

return false; }

} }

(26)

return true; }

public bool checktext(RichTextBox teks) {

int x = teks.TextLength; string tanda = " "; char temp;

for (int j = 0; j < x; j++) {

temp = teks.Text[j];

tanda = tukarposisi(tanda, temp); if (tanda == "**ALES**")

{

MessageBox.Show("Teks yang akan di embed mengandung Kunci");

return false; }

}

MessageBox.Show("Teks anda dapat di embed"); return true;

}

public string tukarposisi(string kata, char huruf) {

string hasil="";

hasil = kata.Substring(1, kata.Length-1); hasil += huruf;

return hasil; }

}

## 9. Class hitungMSEClass

using System;

using System.Collections.Generic; using System.Linq;

using System.Text; using System.Drawing;

namespace TA_091401006_alespanjaitan {

class hitungMseClass {

public double hitung(Bitmap g1, Bitmap g2) {

double nilaimse = 0;

for (int i = 0; i < g1.Width; i++) {

for (int j = 0; j < g1.Height; j++) {

nilaimse += (Math.Pow(g1.GetPixel(i, j).R - g2.GetPixel(i, j).R, 2) +

(27)

} }

nilaimse = nilaimse / (g1.Width * g1.Height); return nilaimse;

} } }

## 10. Class prosesBilangan

using System;

using System.Collections.Generic; using System.Linq;

using System.Text; using System.Numerics;

namespace TA_091401006_alespanjaitan {

class prosesBilangan {

public BigInteger acak(BigInteger a, BigInteger Zi,

BigInteger m)

{

BigInteger c =

BigInteger.Parse(DateTime.Now.Millisecond.ToString());

return ((a * Zi + c) % m); }

public UInt16 ceksuku(BigInteger n) {

UInt16 status = 1; while (n > 255) {

n = n / 256; status += 1; }

return status; }

public BigInteger FPB(BigInteger a, BigInteger b) {

BigInteger c; if (a < b) {

c = a; a = b; b = c; }

if (b <= 1) {

return b; }

c = a - b;

return FPB(b, c); }

public BigInteger moduloexponensial(BigInteger a, BigInteger

b, BigInteger c)

(28)

BigInteger hasil = 1; if (b == 1)

hasil = (a % c); else if (b == 0) hasil = (1 % c); else if (b > 1) {

hasil =

moduloexponensial(BigInteger.Pow(moduloexponensial (a, b / 2, c), 2) * moduloexponensial(a, b % 2, c), 1, c);

}

return hasil; }

public BigInteger bangkitprima(BigInteger bwh, BigInteger atas)

{

bool kondisi = true;

BigInteger hasil = 1, akar; hasil = acak(bwh, hasil, atas); while (kondisi)

{

kondisi = false;

while (moduloexponensial(2, (hasil - 1), hasil) != 1) {

hasil = acak(bwh, hasil, atas); }

akar = (BigInteger)BigInteger.Log(hasil, 2); for (BigInteger i = 2; i <= akar; i++)

{

if (hasil % i == 0) {

kondisi = true; break;

} } }

return hasil; }

} }

## 11. Class inputOutput

using System;

using System.Collections.Generic; using System.Linq;

using System.Text; using System.IO; using System.Drawing;

using System.Windows.Forms;

namespace TA_091401006_alespanjaitan {

class inputOutput {

(29)

{

RichTextBox hasil = new RichTextBox();

string baca = "";

while (baca != null) {

return hasil; }

public Image bukagbr(string filter) {

OpenFileDialog bukagbr = new OpenFileDialog(); bukagbr.InitialDirectory = "";

bukagbr.Filter = filter; bukagbr.FilterIndex = 1;

bukagbr.RestoreDirectory = true;

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

Image gb = new Bitmap(bukagbr.FileName); return gb;

}

return null; }

public string bukateks() {

OpenFileDialog bukatxt = new OpenFileDialog(); bukatxt.InitialDirectory = "";

bukatxt.Filter = "File Text (*.txt)|*.txt"; bukatxt.FilterIndex = 1;

bukatxt.RestoreDirectory = true;

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

return bacateks_dir(bukatxt.FileName).Text; }

return null; }

public bool spGambar(Image gbr) {

SaveFileDialog simpan = new SaveFileDialog(); if (simpan.ShowDialog() == DialogResult.OK) {

gbr.Save(simpan.FileName + ".bmp",

System.Drawing.Imaging.ImageFormat.Bmp); return true;

}

return false; }

public bool spData(Image gbr, string bilprima, string nilx, string nilai_a)

{

SaveFileDialog simpan = new SaveFileDialog(); if (simpan.ShowDialog() == DialogResult.OK) {

(30)

StreamWriter tulis = new StreamWriter(teks); tulis.WriteLine("NILAIP = " + bilprima); tulis.WriteLine("NILAIX = " + nilx); tulis.Write("NILAIA = " + nilai_a); tulis.Close();

teks.Close();

gbr.Save(simpan.FileName + ".bmp",

System.Drawing.Imaging.ImageFormat.Bmp); return true;

}

return false; }

(31)

## : MySQL

Referensi

Dokumen terkait

Tarif UKT Program Diploma dan Sarjana sebagaimana dimaksud dalam Pasal 3 huruf b, mengikuti ketentuan Peraturan Menteri Riset, Teknologi dan Pendidikan Tinggi

Paket pengadaan ini terbuka untuk penyedia yang teregistrasi pada Layanan Pengadaan Secara Elektronik ( LPSE ) dan memenuhi persyaratan SBU Bidang Arsitektur yang

Berdasarkan Berita Acara Hasil Pelelangan oleh Pokja Pengadaan Barang II Unit Layanan Pengadaan (ULP) Kabupaten Klaten Nomor :.. Paket Pekerjaan (terlampir), Daftar

Penelitian ini dilaksanakan di lahan sawah Balai Benih Induk Padi Murni Tanjung Morawa Dinas Pertanian Provinsi Sumatera Utara dengan ketinggian + 20 meter di atas permukaan

Adalah suatu penggabungan satu atau beberapa badan usaha sehingga merupakan satu kesatuan, DENGAN melebur badan usaha yang bergabung, sehingga membentuk badan usaha yang

Penilaian diri berperan penting bersamaan dengan bergesernya pusat pembelajaran dari guru ke peserta didik yang didasarkan pada konsep belajar mandiri ( autonomous learning ).

• Hak untuk mendapatkan perlindungan hukum dari tindakan konsumen yang beritikad tidak baik. • Hak

Metode/Cara Kerja/Acuan yang Digunakan: dikerjakan secara kelompok menggunakan konsep motivasi dalam konteks perilaku konsumen.. Dekripsi Luaran Tugas yang Dihasilkan: