B-20
} private
void comboBox1_SelectedIndexChanged
object sender,
EventArgs e
{ string
dir = D:Aplikasi Tugas
AkhirTA_091401006_alespanjaitanTA_091401006_al espanjaitanTentang
; try
{ if
comboBox1.Text == Programmer
{ pictureBox1.ImageLocation = dir+
Programmer.jpg ;
richTextBox1.Text = io.bacateks_dirdir + Programmer.ales
.Text; }
else if
comboBox1.Text == Parents
{ pictureBox1.ImageLocation = dir +
parent.jpg ;
richTextBox1.Text = io.bacateks_dirdir + parent.ales
.Text; }
else if
comboBox1.Text == Family
{ pictureBox1.ImageLocation = dir+
Keluarga.jpg ;
richTextBox1.Text = io.bacateks_dirdir + Keluarga.ales
.Text; }
else {
pictureBox1.Image = null
; richTextBox1=
null ;
} }
catch {
MessageBox .Show
Ada Kesalahan ;
} }
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;
namespace TA_091401006_alespanjaitan
Universitas Sumatera Utara
B-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.moduloexponensiala, p - 1 - x, p;
nsuku = bilangan.ceksukup; 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
.Pow256, ii gb1.GetPixelx_asal, i.R;
g1 += BigInteger
.Pow256, ii gb1.GetPixelx_asal, i.G;
b1 += BigInteger
.Pow256, ii gb1.GetPixelx_asal, i.B;
x_asal += 1; }
hasil.SetPixelj, i, Color
.FromArgb255, 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.ceksukup;
Bitmap hasil =
new Bitmap
x1 nsuku, y1; temp = bilangan.moduloexponensialy, k, p;
int x_hasil;
for int
i = 0; i y1; i++ {
x_hasil = 0; for
int j = 0; j x1; j++
{
Universitas Sumatera Utara
B-22
el_r = asal.GetPixelj, i.R; el_g = asal.GetPixelj, i.G;
el_b = asal.GetPixelj, 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.SetPixelx_hasil, i, Color
.FromArgb255, 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 .ToChargbrstego.GetPixel0, i.R;
tanda += Convert
.ToChargbrstego.GetPixel0, i.G; tanda +=
Convert .ToChargbrstego.GetPixel0, i.B;
tanda += Convert
.ToChargbrstego.GetPixel1, i.R; tanda +=
Convert .ToChargbrstego.GetPixel1, i.G;
tanda += Convert
.ToChargbrstego.GetPixel1, i.B; tanda +=
Convert .ToChargbrstego.GetPixel2, i.R;
tanda += Convert
.ToChargbrstego.GetPixel2, i.G; if
tanda == ALES
{ return
i; }
tanda = ;
} return
0; }
public Bitmap
pisahgbr Bitmap
gbrstego, int
posisi
Universitas Sumatera Utara
B-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.GetPixelj, i.R; g = gbrstego.GetPixelj, i.G;
b = gbrstego.GetPixelj, i.B; hasil.SetPixelj, i,
Color .FromArgb255, 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
.ToChargbrstego.GetPixelj, i.R; }
else if
wrn == 1 {
sementar = Convert
.ToChargbrstego.GetPixelj, i.G; }
else {
sementar = Convert
.ToChargbrstego.GetPixelj, i.B; }
banding = tukarposisibanding,sementar; if
banding == ALES
{ awl_akhr += 1;
} if
banding == ALES
awl_akhr == 2 {
for int
ii = 1; ii teksasli.TextLength - 7; ii++
{ teksasli2.Text += teksasli.Text[ii];
}
Universitas Sumatera Utara
B-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.GetPixeli, j.R; g1 = gbasli.GetPixeli, j.G;
b1 = gbasli.GetPixeli, j.B; hasil.SetPixeli, j,
Color .FromArgb255, 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
{ g1 = sementara.Text[penanda];
penanda++;
Universitas Sumatera Utara
B-25
} if
penanda = sementara.TextLength b1 = 0;
else {
b1 = sementara.Text[penanda]; penanda++;
} hasil.SetPixelk, i+t,
Color .FromArgb255, 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 .ToChargbr.GetPixelj,i.R;
tanda = tukarposisitanda, temp; if
tanda == ALES
{ MessageBox
.Show Citra anda mengandung
kunci ;
return false
; }
temp = Convert
.ToChargbr.GetPixelj, i.G; tanda = tukarposisitanda, temp;
if tanda ==
ALES {
MessageBox .Show
Citra anda mengandung kunci
; return
false ;
} temp =
Convert .ToChargbr.GetPixelj, i.B;
tanda = tukarposisitanda, temp; if
tanda == ALES
{ MessageBox
.Show Citra anda mengandung
kunci ;
return false
; }
} }
MessageBox .Show
Citra anda dapat diembed ;
Universitas Sumatera Utara
B-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 = tukarposisitanda, 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.Substring1, kata.Length-1; hasil += huruf;
return hasil;
} }
9. Class hitungMSEClass