Implementasi Algoritma Kriptografi Massey Omura Dengan Teknik Steganografi Kombinasi End Of File (EOF) Dan First Of File (FOF) Untuk Keamanan Data

  

LISTING PROGRAM

Kode Program Form home_application :

  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 kriptostegano { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form2 fr2 = new Form2(); fr2.ShowDialog(); } private void helpToolStripMenuItem_Click(object sender, EventArgs e) { this.Dispose(); Form3 fr3 = new Form3(); fr3.ShowDialog(); } private void startToolStripMenuItem_Click(object sender, EventArgs e) { this.Dispose(); Form4 fr4 = new Form4(); fr4.ShowDialog(); } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Are you sure to exit this application?", "Exit", MessageBoxButtons.YesNo,

  MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { Application.Exit(); } } } }

  Kode Program Form encryption1 :

  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; using System.Drawing.Imaging; using System.Diagnostics; namespace kriptostegano { public partial class Form4 : Form { BigInteger p, eA; int dA = 0; Image gambar; BigInteger[] Cipher; int[] SCipher; public Form4() { InitializeComponent(); } private void homeToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form1 fr1 = new Form1(); fr1.ShowDialog(); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form2 fr2 = new Form2(); fr2.ShowDialog(); } private void helpToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form3 fr3 = new Form3(); fr3.ShowDialog(); } private void exitToolStripMenuItem_Click(object sender,EventArgs e) { DialogResult dialog = MessageBox.Show("Are you sure to exit this application?", "Exit", MessageBoxButtons.YesNo,

  MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { Application.Exit(); } } private void Form4_Load(object sender, EventArgs e) { btnGeneratekeyA.Enabled = false; opntxt.Enabled = false; btnEncrypt1.Enabled = false; opnCI1.Enabled = false; btnEmbed1.Enabled = false; SaveSI1.Enabled = false; } private void btnGenerateP_Click_1(object sender, EventArgs e) { ulang: Random rndp = new Random(); p = rndp.Next(257, 1000); { prima.Text = Convert.ToString(p); groupBox2.Visible = true; btnGeneratekeyA.Enabled = true; } else { goto ulang; } } private void resetp_Click_1(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Are you sure to reset all the process?", "Reset",

  MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { prima.Text = ""; nilaieA.Text = ""; nilaidA.Text = ""; plain.Text = ""; cipher1enkrip1.Text = ""; sizeci1.Text = ""; textBox5.Text = ""; textBox6.Text = ""; pictureBox1.Image = null; pictureBox2.Image = null; label11.Text = ""; prima.Focus();

  } } public bool Fermat(BigInteger p) { BigInteger a = 0; for (int i = 0; i <= p.ToString().Length; i++) {

  Random rnda = new Random(); a = rnda.Next(2, (int)p); if (!(BigInteger.ModPow(a, p - 1, p).IsOne)) { return false; } } return true; } public BigInteger cariGCD(BigInteger m, BigInteger n) { BigInteger r = m % n; if (r == 0) return n; return cariGCD(n, r); } private void btnGeneratekeyA_Click(object sender,EventArgs e) { ulangeA: Random rndeA = new Random(); eA = rndeA.Next(2, (int)p - 1); if (cariGCD(eA, p) == 1) { nilaieA.Text = Convert.ToString(eA); groupBox2.Visible = true; BigInteger hasil = 0; dA = 0; while (hasil != 1) { dA++; hasil = ((dA * eA) % (p - 1)); if (dA > 100000) { goto ulangeA; } } nilaidA.Text = dA.ToString(); opntxt.Enabled = true; btnEncrypt1.Enabled = true; } else { goto ulangeA;

  } } private void opntxt_Click_1(object sender, EventArgs e) { Stream mystream; OpenFileDialog openDialogEnkrip1 = new OpenFileDialog(); saveDialogEnkrip1.Title = "Open File Text"; openDialogEnkrip1.Filter = "Text|*.txt"; if (openDialogEnkrip1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if ((mystream = openDialogEnkrip1.OpenFile()) != null)

  { string strfilename = openDialogEnkrip1.FileName; string filetext = File.ReadAllText(strfilename); btnEncrypt1.Enabled = true; plain.Text = filetext; } } } private void btnEncrypt1_Click(object sender, EventArgs e) { cipher1enkrip1.Text = ""; string pA = ""; foreach (char c in plaintext) { pA += System.Convert.ToInt32(c).ToString() + " "; } string[] temp = pA.Split(' '); Cipher = new BigInteger[temp.Length]; for (int i = 0; i < Cipher.Length - 1; i++) { Cipher[i] = BigInteger.Pow(BigInteger.Parse(temp[i]), (int)eA) % (int)p; cipher1enkrip1.Text += Cipher[i].ToString() + " "; } SCipher = new int[(temp.Length * 2) - 2]; string mb = ""; string cip; for (int i = 0, j = 0; i < Cipher.Length - 1; i++, j+=2) { cip = Cipher[i].ToString(); if (cip.Length == 1) cip = "000" + cip; else if (cip.Length == 2) cip = "00" + cip; else if (cip.Length == 3) cip = "0" + cip;

  SCipher[j] = Convert.ToInt32(cip.Substring(0, 2)); SCipher[j + 1] = Convert.ToInt32(cip.Substring(2,2)); mb += SCipher[j].ToString() + " " + SCipher[j + 1].ToString() + " "; } MessageBox.Show("Encryption succeed", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); opnCI1.Enabled = true; } private void opnCI1_Click(object sender, EventArgs e) { OpenFileDialog openDialogEnkrip1 = new OpenFileDialog(); openDialogEnkrip1.Filter = "Image Files(*.bmp)|*.bmp"; DialogResult dr = openDialogEnkrip1.ShowDialog(); if (dr == DialogResult.OK) { gambar = Image.FromFile(openDialogEnkrip1.FileName); pictureBox1.Image = gambar; textBox5.Text = gambar.Width.ToString(); textBox6.Text = gambar.Height.ToString(); string path = Path.GetFullPath(openDialogEnkrip1.FileName); FileInfo fileInfo = new FileInfo(path); double fileSizeKB = fileInfo.Length / 1024; double size = Math.Round(fileSizeKB, 2); sizeci1.Text = size.ToString(); btnEmbed1.Enabled = true; } private void btnEmbed1_Click(object sender, EventArgs e) { int limit = plain.TextLength; Stopwatch sw = new Stopwatch(); sw.Start(); Bitmap image = new Bitmap(pictureBox1.Image); int x = image.Width; int y = image.Height; if ((x * 3) - 2 < limit) {

  MessageBox.Show("Message is over limit of image pixel\r\nPlease choose another image,", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Bitmap output = new Bitmap(image.Width, 1); Bitmap output2 = new Bitmap(image.Width, 1); for (int i = 0; i < 1; i++) { for (int j = 0; j < x; j++) { output.SetPixel(j, i, Color.FromArgb(255, 0,

  0, 0)); output2.SetPixel(j, i, Color.FromArgb(255, 0, 0, 0));

  } } int x1 = 0, x2 = 0, index = 0, count = 0; for (int i = 0; i < y; i++) { for (int j = 0; j < x * 2; j++) { if (index == SCipher.Length) goto habis; if (count % 2 == 0) { if (index + 2 == SCipher.Length) { output.SetPixel(x1, i,Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], 0)); index += 2; x1++; count++; } else if (index + 1 == SCipher.Length) { output.SetPixel(x1, i, Color.FromArgb

  (255, (int)SCipher[index], 0, 0)); index++; x1++; count++; } { output.SetPixel(x1, i, Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], (int)SCipher[index + 2])); index += 3; x1++; count++; } } else { if (index + 2 == SCipher.Length) { output2.SetPixel(x2, i,Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], 0)); index += 2; x2++; count++; } else if (index + 1 == SCipher.Length) { output2.SetPixel(x2, i,Color.FromArgb

  (255, (int)SCipher[index], 0, 0)); index++; x2++; count++; } else

  { output2.SetPixel(x2, i,Color.FromArgb (255, (int)SCipher[index], (int)SCipher[index + 1], (int)SCipher[index + 2])); index += 3; x2++; count++; } } } } habis: for (int i = 0; i < 1; i++) { for (int j = 0; j < x; j++) { int r = output.GetPixel(j, i).R; int g = output.GetPixel(j, i).G; int b = output.GetPixel(j, i).B; int r2 = output2.GetPixel(j, i).R; int g2 = output2.GetPixel(j, i).G; int b2 = output2.GetPixel(j, i).B; } } Bitmap outputImage = new Bitmap(image.Width, System.Drawing.Imaging.PixelFormat.Format32bppArgb); using (Graphics graphics = Graphics.FromImage(outputImage)) { graphics.DrawImage(output, new Rectangle(new Point(), output.Size), new Rectangle(new Point(), output.Size), GraphicsUnit.Pixel); graphics.DrawImage(image, new Rectangle(new Point(0, output.Height + 1), image.Size), new Rectangle(new Point(), image.Size), GraphicsUnit.Pixel); graphics.DrawImage(output2, new Rectangle(new Point(0, image.Height + 1), output2.Size), new Rectangle(new Point(), output2.Size), GraphicsUnit.Pixel); } pictureBox2.Image = outputImage; SaveSI1.Enabled = true; sw.Stop(); label11.Text = "Waktu Embed :\r\n " + sw.Elapsed; MessageBox.Show("Embedding succeed\rplease save stego image", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void SaveSI1_Click(object sender, EventArgs e) { SaveFileDialog saveDialogEnkrip1 = new SaveFileDialog(); saveDialogEnkrip1.Title = "Save Stego Image"; saveDialogEnkrip1.Filter = "Image Files(*.bmp)|*.bmp"; if (DialogResult.OK == saveDialogEnkrip1.ShowDialog()) { pictureBox2.Image.Save(saveDialogEnkrip1.FileName, ImageFormat.Bmp); MessageBox.Show("Stego Image Saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void next1_Click(object sender, EventArgs e) { this.Hide(); Form5 fr5 = new Form5(); fr5.ShowDialog(); } } }

  Kode Program Form encryption2 :

  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; using System.Drawing.Imaging; using System.Diagnostics; namespace kriptostegano { public partial class Form5 : Form { BigInteger eB; int dB = 0; Bitmap newBitmap; Image gambar; BigInteger[] Cipher; int[] SCipher; public Form5() { InitializeComponent(); } private void homeToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form1 fr1 = new Form1(); fr1.ShowDialog(); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form2 fr2 = new Form2(); fr2.ShowDialog(); } private void helpToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form3 fr3 = new Form3(); fr3.ShowDialog(); } private void startToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form4 fr4 = new Form4(); fr4.ShowDialog(); } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Are you sure to exit this application?", "Exit", MessageBoxButtons.YesNo, if (dialog == DialogResult.Yes) { Application.Exit(); } } private void Form5_Load(object sender, EventArgs e) { GroupBox grup = Application.OpenForms["Form4"].

  Controls["groupBox1"] as GroupBox; TextBox nilaiP = grup.Controls["prima"] as TextBox; prima1.Text = nilaiP.Text; btnExtract1.Enabled = false; btnGeneratekeyB.Enabled = false; btnEncrypt2.Enabled = false; opnCI2.Enabled = false; btnEmbed2.Enabled = false; SaveSI2.Enabled = false; } private void opnSI1_Click_1(object sender, EventArgs e) { OpenFileDialog openDialogEnkrip2 = new OpenFileDialog(); openDialogEnkrip2.Title = "Open Stego Image"; openDialogEnkrip2.Filter = "Bitmaps|*.Bmp"; DialogResult dr = openDialogEnkrip2.ShowDialog(); if (dr == DialogResult.OK) { gambar = Image.FromFile(openDialogEnkrip2.FileName); newBitmap = new Bitmap(openDialogEnkrip2.FileName); pictureBox3.Image = gambar; btnExtract1.Enabled = true; } } private void btnExtract1_Click(object sender, EventArgs e) { Stopwatch sw = new Stopwatch(); sw.Start(); Bitmap image = new Bitmap(pictureBox3.Image); int x = image.Width; int y = image.Height; string px = ""; int r, g, b; string strR, strG, strB; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { if (j == 0 || j == y - 1) { r = image.GetPixel(i, j).R; if (r.ToString().Length == 1) strR = "0" + r; strR = r.ToString(); g = image.GetPixel(i, j).G; if (g.ToString().Length == 1) strG = "0" + g; else strG = g.ToString(); b = image.GetPixel(i, j).B; if (b.ToString().Length == 1) strB = "0" + b; else strB = b.ToString(); px += strR + " " + strG + " " + strB + " "; } } } int count = 1; for (int i = 0; i < px.Length; i++) { if (px[i] == ' ') { if (count % 2 != 0) px = px.Remove(i, 1); count++; } } int index = px.IndexOf(" 0000 0000"); if (index < 0) {

  DialogResult dialognohidden = MessageBox.Show("no hidden message\rplease input another image", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);

  } else { px = px.Substring(0, index); string[] temp = px.Split(' '); px = ""; for (int i = 0; i < temp.Length; i++) { px += Convert.ToInt32(temp[i]) + " "; } cipher1enkrip2.Text = px; sw.Stop(); label13.Text = "Waktu Extract :\r\n " + sw.Elapsed; MessageBox.Show("Extracting succeed\r please input p and generate key", "Info", MessageBoxButtons.OK,

  MessageBoxIcon.Information); btnGeneratekeyB.Enabled = true; } } public BigInteger cariGCD(BigInteger m, BigInteger n) { if (r == 0) return n; return cariGCD(n, r); } private void btnGeneratekeyB_Click(object sender,EventArgs e) { ulangeB: Random rndeB = new Random(); eB = rndeB.Next(2, (Convert.ToInt32(prima1.Text) - 1)); if (cariGCD(eB, Convert.ToInt32(prima1.Text)) == 1) { nilaieB.Text = Convert.ToString(eB); BigInteger hasil = 0; dB = 0; while (hasil != 1) { dB++; hasil = ((dB * eB) % (Convert.ToInt32(prima1.Text) - 1)); if (dB > 100000) { goto ulangeB; } } nilaidB.Text = dB.ToString(); btnEncrypt2.Enabled = true; } else { goto ulangeB; } } private void btnEncrypt2_Click(object sender, EventArgs e) { string plaintext = cipher1enkrip2.Text; cipher2enkrip2.Text = ""; string[] temp = plaintext.Split(' ');

  Cipher = new BigInteger[temp.Length]; for (int i = 0; i < Cipher.Length - 1; i++) { Cipher[i] = BigInteger.Pow(BigInteger.Parse(temp[i]),

  (int)eB) % (int)Convert.ToInt32(prima1.Text); cipher2enkrip2.Text += Cipher[i].ToString() + " "; } SCipher = new int[(temp.Length * 2) - 2]; string mb = ""; string cip; for (int i = 0, j = 0; i < Cipher.Length - 1; i++, j+=2) { cip = Cipher[i].ToString(); if (cip.Length == 1) cip = "000" + cip; else if (cip.Length == 2) cip = "00" + cip; cip = "0" + cip; SCipher[j] = Convert.ToInt32(cip.Substring(0, 2)); SCipher[j + 1] = Convert.ToInt32(cip.Substring(2,2)); mb += SCipher[j].ToString() + " " + SCipher[j +1]. ToString() + " "; } MessageBox.Show("Encryption succeed", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); opnCI2.Enabled = true; } private void opnCI2_Click_1(object sender, EventArgs e) { OpenFileDialog openDialogEnkrip2 = new OpenFileDialog(); openDialogEnkrip2.Title = "Open Cover Image"; openDialogEnkrip2.Filter = "Image Files(*.bmp)|*.bmp"; DialogResult dr = openDialogEnkrip2.ShowDialog(); if (dr == DialogResult.OK) { gambar = Image.FromFile(openDialogEnkrip2.FileName); newBitmap = new Bitmap(openDialogEnkrip2.FileName); pictureBox1.Image = gambar; textBox5.Text = gambar.Width.ToString(); textBox6.Text = gambar.Height.ToString(); string path = Path.GetFullPath(openDialogEnkrip2.FileName);

  FileInfo fileInfo = new FileInfo(path); double fileSizeKB = fileInfo.Length / 1024; sizeci2.Text = fileSizeKB.ToString(); btnEmbed2.Enabled = true; } } private void btnEmbed2_Click(object sender, EventArgs e) { Stopwatch sw = new Stopwatch(); sw.Start(); Bitmap image = new Bitmap(pictureBox1.Image); int x = image.Width; int y = image.Height; if ((x * 3 * 2) - 4 < SCipher.Length) {

  MessageBox.Show("Message is over limit of image pixel\r\nPlease choose another image,", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

  } else { string px = "", px2 = ""; Bitmap output = new Bitmap(image.Width, 1); Bitmap output2 = new Bitmap(image.Width, 1); for (int i = 0; i < 1; i++) { for (int j = 0; j < x; j++) {

  (255, 0, 0, 0)); output2.SetPixel(j, i, Color.FromArgb (255, 0, 0, 0));

  } } int x1 = 0, x2 = 0, index = 0, count = 0; for (int i = 0; i < y; i++) { for (int j = 0; j < x * 2; j++) { if (index == SCipher.Length) goto habis; if (count % 2 == 0) { if (index + 2 == SCipher.Length) { output.SetPixel(x1, i, Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], 0)); index += 2; x1++; count++; } else if (index + 1 == SCipher.Length) { output.SetPixel(x1, i, Color.FromArgb

  (255, (int)SCipher[index], 0, 0)); index++; x1++; count++; } else { output.SetPixel(x1, i, Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], (int)SCipher[index + 2])); index += 3; x1++; count++; } } else { if (index + 2 == SCipher.Length) { output2.SetPixel(x2, i,Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], 0)); index += 2; x2++; count++; } else if (index + 1 == SCipher.Length) { output2.SetPixel(x2, i,Color.FromArgb

  (255, (int)SCipher[index], 0, 0)); index++; count++; } else { output2.SetPixel(x2, i,Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], (int)SCipher[index + 2])); index += 3; x2++; count++; } } } } habis: for (int i = 0; i < 1; i++) { for (int j = 0; j < x; j++) { int r = output.GetPixel(j, i).R; int g = output.GetPixel(j, i).G; int b = output.GetPixel(j, i).B; px += r.ToString() + " " + g.ToString() + " "

  • b.ToString() + "\r\n"; int r2 = output2.GetPixel(j, i).R; int g2 = output2.GetPixel(j, i).G; int b2 = output2.GetPixel(j, i).B;
px2 += r2.ToString() + " " + g2.ToString() + " " + b2.ToString() + "\r\n";

  } } Bitmap outputImage = new Bitmap(image.Width, image.Height + 2,System.Drawing.Imaging.

  PixelFormat.Format32bppArgb); using (Graphics graphics = Graphics.FromImage(outputImage)) { graphics.DrawImage(output, new Rectangle

  (new Point(), output.Size), new Rectangle(new Point(), output.Size), GraphicsUnit.Pixel); graphics.DrawImage(image, new Rectangle

  (new Point(0, output.Height + 1), image.Size), new Rectangle(new Point(), image.Size), GraphicsUnit.Pixel); graphics.DrawImage(output2, new Rectangle

  (new Point(0, image.Height + 1), output2.Size), new Rectangle(new Point(), output2.Size), GraphicsUnit.Pixel); } pictureBox2.Image = outputImage; sw.Stop(); label12.Text = "Waktu Embed :\r\n " + sw.Elapsed; DialogResult dialog = MessageBox.Show("Embedding succeed\rplease save stego image", "Info", SaveSI2.Enabled = true; } } private void SaveSI2_Click_1(object sender, EventArgs e) { SaveFileDialog saveDialogenkrip2 = new SaveFileDialog(); saveDialogenkrip2.Title = "Save Stego Image"; saveDialogEnkrip2.Filter = "Image Files(*.bmp)|*.bmp"; if (DialogResult.OK == saveDialogEnkrip2.ShowDialog()) { pictureBox2.Image.Save(saveDialogEnkrip2.FileName,

  ImageFormat.Bmp); { MessageBox.Show("Stego Image Saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } private void next2_Click(object sender, EventArgs e) { this.Hide(); Form6 fr6 = new Form6(); fr6.ShowDialog(); } } }

  Kode Program Form decryption1 :

  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; using System.Drawing.Imaging; using System.Diagnostics; namespace kriptostegano { public partial class Form6 : Form { Bitmap newBitmap; Image gambar; BigInteger[] Cipher; int[] SCipher; public Form6() { InitializeComponent(); } private void homeToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form1 fr1 = new Form1(); fr1.ShowDialog(); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form2 fr2 = new Form2(); fr2.ShowDialog(); } private void helpToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form3 fr3 = new Form3(); fr3.ShowDialog(); } private void startToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form4 fr4 = new Form4(); fr4.ShowDialog(); } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Are you sure to exit this application?", "Exit", MessageBoxButtons.YesNo,

  MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { Application.Exit(); } } private void Form6_Load(object sender, EventArgs e) { GroupBox grup = Application.OpenForms["Form4"].

  Controls["groupBox1"] as GroupBox; TextBox nilaiP = grup.Controls["prima"] as TextBox; prima2.Text = nilaiP.Text; GroupBox grup2 = Application.OpenForms["Form4"].

  Controls["groupBox3"] as GroupBox; GroupBox grup3 = grup2.Controls["groupBox2"] as GroupBox; TextBox dA = grup3.Controls["nilaidA"] as TextBox; nilaidA2.Text = dA.Text; btnExtract2.Enabled = false; btnDecrypt1.Enabled = false; opnCI3.Enabled = false; btnEmbed3.Enabled = false; SaveSI3.Enabled = false; } private void opnSI2_Click_1(object sender, EventArgs e) { OpenFileDialog openDialogDekrip1 = new OpenFileDialog(); openDialogDekrip1.Title = "Open Stego Image"; openDialogDekrip1.Filter = "Image Files(*.bmp)|*.bmp"; DialogResult dr = openDialogDekrip1.ShowDialog(); if (dr == DialogResult.OK) { gambar = Image.FromFile(openDialogDekrip1.FileName); newBitmap = new Bitmap(openDialogDekrip1.FileName); pictureBox3.Image = gambar; btnExtract2.Enabled = true; } } private void btnExtract2_Click(object sender, EventArgs e) { Stopwatch sw = new Stopwatch(); sw.Start(); Bitmap image = new Bitmap(pictureBox3.Image); int x = image.Width; int y = image.Height; string px = ""; int r, g, b; string strR, strG, strB; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { if (j == 0 || j == y - 1) { r = image.GetPixel(i, j).R; if (r.ToString().Length == 1) strR = "0" + r; else strR = r.ToString(); g = image.GetPixel(i, j).G; if (g.ToString().Length == 1) strG = "0" + g; else strG = g.ToString(); b = image.GetPixel(i, j).B; if (b.ToString().Length == 1) strB = "0" + b; else strB = b.ToString(); px += strR + " " + strG + " " + strB + " "; } } } int count = 1; for (int i = 0; i < px.Length; i++) { if (px[i] == ' ') { if (count % 2 != 0) px = px.Remove(i, 1); count++; } int index = px.IndexOf(" 0000 0000"); if (index < 0) { MessageBox.Show("no hidden message\rplease input another image", "Info", MessageBoxButtons.OK,

  MessageBoxIcon.Warning); } else { px = px.Substring(0, index); string[] temp = px.Split(' '); px = ""; for (int i = 0; i < temp.Length; i++) { px += Convert.ToInt32(temp[i]) + " "; } cipher2dekrip1.Text = px; sw.Stop(); label11.Text = "Waktu Extract :\r\n " + sw.Elapsed; MessageBox.Show("Extracting succeed\r please input p and dA", "Info", MessageBoxButtons.OK,

  MessageBoxIcon.Information); btnDecrypt1.Enabled = true; } } private void btnDecrypt1_Click(object sender, EventArgs e) { string plaintext = cipher2dekrip1.Text; cipher3dekrip1.Text = ""; string[] temp = plaintext.Split(' ');

  Cipher = new BigInteger[temp.Length]; for (int i = 0; i < Cipher.Length - 1; i++) { Cipher[i] = BigInteger.Pow(BigInteger.Parse(temp[i]),

  (int)Convert.ToInt32(nilaidA2.Text)) % (int)Convert.ToInt32(prima2.Text); cipher3dekrip1.Text += Cipher[i].ToString() + " ";

  } SCipher = new int[(temp.Length * 2) - 2]; string mb = ""; string cip; for (int i = 0, j = 0; i < Cipher.Length - 1; i++, j +=2) { cip = Cipher[i].ToString(); if (cip.Length == 1) cip = "000" + cip; else if (cip.Length == 2) cip = "00" + cip; else if (cip.Length == 3) cip = "0" + cip; SCipher[j] = Convert.ToInt32(cip.Substring(0, 2)); SCipher[j + 1] = Convert.ToInt32(cip.Substring(2,2)); mb += SCipher[j].ToString() + " " + SCipher[j + 1].ToString() + " "; MessageBox.Show("Decryption succeed", "Info",

  MessageBoxButtons.OK, MessageBoxIcon.Information); opnCI3.Enabled = true; } private void opnCI3_Click_1(object sender, EventArgs e) { OpenFileDialog openDialogDekrip1 = new OpenFileDialog(); openDialogDekrip1.Title = "Open Cover Image"; openDialogDekrip1.Filter = "Image Files(*.bmp)|*.bmp"; DialogResult dr = openDialogDekrip1.ShowDialog(); if (dr == DialogResult.OK) { gambar = Image.FromFile(openDialogDekrip1.FileName); newBitmap = new Bitmap(openDialogDekrip1.FileName); pictureBox1.Image = gambar; textBox5.Text = gambar.Width.ToString(); textBox6.Text = gambar.Height.ToString(); string path =

  Path.GetFullPath(openDialogDekrip1.FileName); FileInfo fileInfo = new FileInfo(path); double fileSizeKB = fileInfo.Length / 1024; sizeci3.Text = fileSizeKB.ToString(); btnEmbed3.Enabled = true; } } private void btnEmbed3_Click(object sender, EventArgs e)

  { Stopwatch sw = new Stopwatch(); sw.Start(); Bitmap image = new Bitmap(pictureBox1.Image); int x = image.Width; int y = image.Height; if ((x * 3 * 2) - 4 < SCipher.Length) {

  MessageBox.Show("Message is over limit of image pixel\r\nPlease choose another image,", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

  } else { string px = "", px2 = ""; Bitmap output = new Bitmap(image.Width, 1); Bitmap output2 = new Bitmap(image.Width, 1); for (int i = 0; i < 1; i++) { for (int j = 0; j < x; j++) { output.SetPixel(j, i, Color.FromArgb

  (255, 0, 0, 0)); output2.SetPixel(j, i, Color.FromArgb (255, 0, 0, 0));

  } } int x1 = 0, x2 = 0, index = 0, count = 0; { for (int j = 0; j < x * 2; j++) { if (index == SCipher.Length) goto habis; if (count % 2 == 0) { if (index + 2 == SCipher.Length) { output.SetPixel(x1, i, Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], 0)); index += 2; x1++; count++; } else if (index + 1 == SCipher.Length) { output.SetPixel(x1, i, Color.FromArgb

  (255, (int)SCipher[index], 0, 0)); index++; x1++; count++; } else { output.SetPixel(x1, i, Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index

  • 1], (int)SCipher[index + 2]));
index += 3; x1++; count++; } } else { if (index + 2 == SCipher.Length) { output2.SetPixel(x2, i,Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], 0)); index += 2; x2++; count++; } else if (index + 1 == SCipher.Length) { output2.SetPixel(x2, i,Color.FromArgb

  (255, (int)SCipher[index], 0, 0)); index++; x2++; count++; } else { output2.SetPixel(x2, i,Color.FromArgb

  (255, (int)SCipher[index], (int)SCipher[index + 1], index += 3; x2++; count++; } } } } habis: for (int i = 0; i < 1; i++) { for (int j = 0; j < x; j++) { int r = output.GetPixel(j, i).R; int g = output.GetPixel(j, i).G; int b = output.GetPixel(j, i).B; px += r.ToString() + " " + g.ToString() + " "

  • b.ToString() + "\r\n"; int r2 = output2.GetPixel(j, i).R; int g2 = output2.GetPixel(j, i).G; int b2 = output2.GetPixel(j, i).B; px2 += r2.ToString() + " " + g2.ToString() + " " + b2.ToString() + "\r\n"; } } Bitmap outputImage = new Bitmap(image.Width, image.Height + 2, System.Drawing.Imaging. PixelFormat.Format32bppArgb);
using (Graphics graphics = Graphics.FromImage(outputImage)) { graphics.DrawImage(output, new Rectangle(new Point(), output.Size), new Rectangle(new Point(), output.Size), GraphicsUnit.Pixel); graphics.DrawImage(image, new Rectangle(new Point(0, output.Height + 1), image.Size), new Rectangle(new Point(), image.Size), GraphicsUnit.Pixel); graphics.DrawImage(output2, new Rectangle

  (new Point(0, image.Height + 1), output2.Size), new Rectangle(new Point(), output2.Size), GraphicsUnit.Pixel);

  } pictureBox2.Image = outputImage; sw.Stop(); label12.Text = "Waktu Embed :\r\n " + sw.Elapsed; DialogResult dialog = MessageBox.Show("Embedding succeed\rplease save stego image", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); SaveSI3.Enabled = true; } } private void SaveSI3_Click_1(object sender, EventArgs e) { SaveFileDialog saveDialogDekrip1 = new SaveFileDialog(); saveDialogDekrip1.Title = "Save Stego Image"; saveDialogDekrip1.Filter = "Image Files(*.bmp)|*.bmp"; if (DialogResult.OK == saveDialogDekrip1.ShowDialog()) { pictureBox2.Image.Save(saveDialogDekrip1.FileName, ImageFormat.Bmp); { MessageBox.Show("Stego Image Saved", "Info", MessageBoxButtons.OK,MessageBoxIcon.Information); } } } private void next3_Click(object sender, EventArgs e) { this.Hide(); Form7 fr7 = new Form7(); fr7.ShowDialog(); } } }

  Kode Program Form decryption2 :

  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.Drawing.Imaging; using System.Numerics; using System.Diagnostics; namespace kriptostegano { public partial class Form7 : Form { Bitmap newBitmap; Image gambar; public Form7() { InitializeComponent(); } private void homeToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form1 fr1 = new Form1(); fr1.ShowDialog(); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form2 fr2 = new Form2(); fr2.ShowDialog(); } private void helpToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form3 fr3 = new Form3(); fr3.ShowDialog(); } private void startToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); Form4 fr4 = new Form4(); fr4.ShowDialog(); } private void exitToolStripMenuItem_Click(object sender, EventArgs e)

  { DialogResult dialog = MessageBox.Show("Are you sure to exit this application?", "Exit", MessageBoxButtons.YesNo,

  MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { Application.Exit(); } } private void Form7_Load(object sender, EventArgs e) { GroupBox grup = Application.OpenForms["Form4"].

  Controls["groupBox1"] as GroupBox; TextBox nilaiP = grup.Controls["prima"] as TextBox; prima3.Text = nilaiP.Text; GroupBox grup2 = Application.OpenForms["Form5"]. Controls["groupBox3"] as GroupBox; GroupBox grup3 = grup2.Controls["groupBox2"] as GroupBox;

  TextBox dB = grup3.Controls["nilaidB"] as TextBox; textBox3.Text = dB.Text; btnExtract3.Enabled = false; btnDecrypt2.Enabled = false; saveplainawal.Enabled = false; private void opnSI3_Click_1(object sender, EventArgs e) { OpenFileDialog openDialogDekrip2 = new OpenFileDialog(); openDialogDekrip2.Title = "Open Stego Image"; openDialogDekrip2.Filter = "Image Files(*.bmp)|*.bmp"; DialogResult dr = openDialogDekrip2.ShowDialog(); if (dr == DialogResult.OK) { gambar = Image.FromFile(openDialogDekrip2.FileName); newBitmap = new Bitmap(openDialogDekrip2.FileName); pictureBox3.Image = gambar; btnExtract3.Enabled = true; } } private void btnExtract3_Click(object sender, EventArgs e) { Stopwatch sw = new Stopwatch(); sw.Start(); Bitmap image = new Bitmap(pictureBox3.Image); int x = image.Width; int y = image.Height; string px = ""; int r, g, b; string strR, strG, strB; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { if (j == 0 || j == y - 1) { r = image.GetPixel(i, j).R; if (r.ToString().Length == 1) strR = "0" + r; else strR = r.ToString(); g = image.GetPixel(i, j).G; if (g.ToString().Length == 1) strG = "0" + g; else strG = g.ToString(); b = image.GetPixel(i, j).B; if (b.ToString().Length == 1) strB = "0" + b; else strB = b.ToString(); px += strR + " " + strG + " " + strB + " "; } } } int count = 1; for (int i = 0; i < px.Length; i++) { if (px[i] == ' ') { if (count % 2 != 0) count++; } } int index = px.IndexOf(" 0000 0000"); if (index < 0) { DialogResult dialognohidden = MessageBox.Show("no hidden message\rplease input another image", "Info",

  MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { px = px.Substring(0, index); string[] temp = px.Split(' '); px = ""; for (int i = 0; i < temp.Length; i++) { px += Convert.ToInt32(temp[i]) + " "; } cipher3dekrip2.Text = px; sw.Stop(); label1.Text = "Waktu Extract :\r\n " + sw.Elapsed; DialogResult dialogextract = MessageBox.Show("Extracting succeed\rplease input p and dB", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); btnDecrypt2.Enabled = true; } } private void btnDecrypt2_Click(object sender, EventArgs e) { BigInteger dB = BigInteger.Parse(textBox3.Text); string tes = cipher3dekrip2.Text; string[] temp = tes.Split(' '); BigInteger[] Cipher = new BigInteger[temp.Length]; string ascii; for (int i = 0; i < Cipher.Length - 1; i++) { Cipher[i] = BigInteger.Pow(BigInteger.Parse(temp[i]), (int)Convert.ToInt32(textBox3.Text)) % (int)Convert.ToInt32(prima3.Text); ascii =char.ConvertFromUtf32(Convert.ToInt32 (Cipher[i].ToString())); plainawal.Text += ascii; { saveplainawal.Enabled = true; } } MessageBox.Show("Decryption succeed", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void saveplainawal_Click(object sender, EventArgs e) { SaveFileDialog saveFileDekrip2 = new SaveFileDialog(); saveFileDekrip2.Title = "Save text Files"; saveFileDekrip2.Filter = "txt files (*.txt)|*.txt"; { using (Stream s = File.Open(saveFileDekrip2.FileName, FileMode.CreateNew)) using (StreamWriter sw = new StreamWriter(s)) { sw.Write(plainawal.Text); MessageBox.Show("plaintext saved", "Info", MessageBoxButtons.OK,MessageBoxIcon.Information); } } } } }

  Nama : Nadya Soraya Hardiyana Tempat/Tanggal Lahir : Jakarta, 29 Juli 1991 Agama : Islam Alamat Sekarang : Jl. Gaharu No. 69/71 Kel. Gaharu Kec. Medan Timur 20235 Alamat Orang Tua : Jl. Gaharu No. 69/71 Kel. Gaharu Kec. Medan Timur 20235 Telp/ Hp : 085297166373 Email : nadyasorayah@gmail.com Riwayat Pendidikan 2009 – 2013 : S1 Ilmu Komputer Universitas Sumatera Utara, Medan 2006 – 2009 : SMA Negeri 3 Medan 2003 – 2006 : SMP Negeri 75 Jakarta Barat 1997 – 2003 : SD Negeri 01 Kedoya Utara, Jakarta Barat Pengalaman Organisasi dan Kegiatan Ilmiah

   (IMILKOM), 2010-2011

Ketua Departemen Jurnalistik Ikatan Mahasiswa S1 Ilmu Komputer (IMILKOM),

  

Anggota Departemen Jurnalistik Ikatan Mahasiswa S1 Ilmu Komputer

   2011-2012

Anggota Departemen Humas Pemerintahan Mahasiswa Fakultas Ilmu Komputer

 dan Teknologi Informasi (PEMA FASILKOM-TI) 2012-2013 Praktek Kerja Lapangan di PDAM Tirtanadi Medan, Juli-Agustus 2012 