-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
157 lines (135 loc) · 5.11 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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 Microsoft.DirectX.AudioVideoPlayback;
using System.IO;
namespace susdulukripto
{
public partial class Form1 : Form
{
private Microsoft.DirectX.AudioVideoPlayback.Video video;
public bool isHideAllowed;
internal SaveFileDialog SaveFileDialog1;
public Form1()
{
InitializeComponent();
isHideAllowed = false;
this.SaveFileDialog1 = new SaveFileDialog();
}
private void button3_Click(object sender, EventArgs e)
{
//get message size in bit
int mbit = System.IO.File.ReadAllBytes(openMessageDialog.FileName).Length * 8;
//get cover object size in byte
byte[] csize = System.IO.File.ReadAllBytes(openAviDialog.FileName);
int cbyte = csize.Length;
//compare
if(cbyte < mbit)
{
MessageBox.Show("Ukuran file terlalu besar","Warning",MessageBoxButtons.OK);
}
else
{
isHideAllowed = true;
MessageBox.Show("Proses penyembunyian pesan bisa dilakukan", "Info", MessageBoxButtons.OK);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (openMessageDialog.ShowDialog() == DialogResult.OK)
{
Console.WriteLine(openMessageDialog.FileName);
}
}
private void button4_Click(object sender, EventArgs e)
{
if(video.State != StateFlags.Running)
{
video.Play();
}
}
private void button5_Click(object sender, EventArgs e)
{
if(video.State == StateFlags.Running)
{
video.Pause();
}
}
private void button1_Click(object sender, EventArgs e)
{
if(openAviDialog.ShowDialog() == DialogResult.OK)
{
int width = panel1.Width;
int height = panel1.Height;
video = new Microsoft.DirectX.AudioVideoPlayback.Video(openAviDialog.FileName);
video.Owner = panel1;
video.Stop();
panel1.Size = new Size(width,height);
}
}
private void button6_Click(object sender, EventArgs e)
{
if(video.State != StateFlags.Stopped)
{
video.Stop();
}
}
private void button7_Click(object sender, EventArgs e)
{
if(isHideAllowed)
{
//create message
String fname = openMessageDialog.SafeFileName;
String[] fstr = fname.Split('.');
Message m = new Message(fstr[0], fstr[1], System.IO.File.ReadAllBytes(openMessageDialog.FileName));
if (VigenereMode.Text == "Use Vigenere")
{
m.VigenereEncrypt(textBox2.Text);
}
//save file dialog
if (saveAviDialog.ShowDialog() == DialogResult.OK)
{
//susdulukriptio.video instatiation
Video video = new Video(openAviDialog.FileName, saveAviDialog.FileName, textBox2.Text);
video.hide(m.compose(), lsbMode.Text == "1 LSB");
}
}
else
{
MessageBox.Show("Lengkapi data & uji payload terlebih dahulu", "Warning", MessageBoxButtons.OK);
}
}
private void button8_Click(object sender, EventArgs e)
{
Video video = new Video(openAviDialog.FileName, saveAviDialog.FileName, textBox2.Text);
Message m = video.extract(openAviDialog.FileName, lsbMode.Text=="1 LSB");
if (VigenereMode.Text == "Use Vigenere")
{
m.VigenereDecrypt(textBox2.Text);
}
SaveFileDialog1.FileName = m.filename;
SaveFileDialog1.DefaultExt = m.extension;
DialogResult result = SaveFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
File.WriteAllBytes(SaveFileDialog1.FileName, m.content);
}
}
private void PSNR_Click(object sender, EventArgs e)
{
PSNRlabel.Text = "Processing PSNR";
if (openMessageDialog.ShowDialog() == DialogResult.OK)
{
String fname = openMessageDialog.FileName;
Video video = new Video(openAviDialog.FileName, saveAviDialog.FileName, textBox2.Text);
Video video2 = new Video(fname, saveAviDialog.FileName, textBox2.Text);
PSNRlabel.Text = "PSNR = "+ (Math.Round(video.compPSNR(video2)*100)/100).ToString();
}
}
}
}