[WIP] encode/decode
This commit is contained in:
parent
24f9c37af3
commit
a35afc3aa1
|
@ -110,6 +110,7 @@
|
|||
this.button2.TabIndex = 6;
|
||||
this.button2.Text = "get";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
|
|
93
main_form.cs
93
main_form.cs
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
@ -21,6 +22,8 @@ namespace KRY_0x02
|
|||
|
||||
public int im_h = 0;
|
||||
public int im_w = 0;
|
||||
public static int cap = 0;
|
||||
public string path = "";
|
||||
|
||||
public string getpath(TextBox t)
|
||||
{
|
||||
|
@ -34,27 +37,71 @@ namespace KRY_0x02
|
|||
a = im_h;
|
||||
b = im_w;
|
||||
c = ((a * b) / 8) - 8;
|
||||
cap = c;
|
||||
return c;
|
||||
}
|
||||
|
||||
//Bitmap my_bitmap = new Bitmap(getpath(textBox1));
|
||||
Color pixel;
|
||||
int int_value;
|
||||
//for (int i = 0; i<my_bitmap.Witdh - 1; i++)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
|
||||
class do_a_stego
|
||||
{
|
||||
public string putthere()
|
||||
Bitmap my_bitmap;// = new Bitmap(getpath(textBox1));
|
||||
Color pixel;
|
||||
|
||||
byte bit_array_to_byte(BitArray bit_array)
|
||||
{
|
||||
byte[] byte_array = new byte[1];
|
||||
//if (bit_array.Count == cap)
|
||||
if (bit_array.Count == 8)
|
||||
{
|
||||
bit_array.CopyTo(byte_array, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte_array[0] = 0;
|
||||
MessageBox.Show($"you should have {bit_array.Count} bits for a byte bro", "error happened");
|
||||
}
|
||||
return byte_array[0];
|
||||
}
|
||||
|
||||
public string encode(Bitmap b, string m)
|
||||
{
|
||||
/* WIP */
|
||||
my_bitmap = b;
|
||||
string message = m;
|
||||
for (int i = 0; i < my_bitmap.Width - 1; i++)
|
||||
{
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public string gimme()
|
||||
|
||||
public string gimme(Bitmap b)
|
||||
{
|
||||
return "";
|
||||
/* WIP */
|
||||
my_bitmap = b;
|
||||
bool[] my_bool_array = new bool[8];
|
||||
int int_value;
|
||||
|
||||
int ii = my_bool_array.Length - 1;
|
||||
|
||||
for (int i = 0; i < my_bitmap.Width - 1; i++)
|
||||
{
|
||||
pixel = my_bitmap.GetPixel(i, 0);
|
||||
int_value = pixel.B;
|
||||
|
||||
if ((int_value & 1) == 0)
|
||||
{
|
||||
my_bool_array[i] = false;
|
||||
}
|
||||
else if ((int_value & 1) == 1)
|
||||
{
|
||||
my_bool_array[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
BitArray my_bit_array = new BitArray(my_bool_array);
|
||||
char my_char = Convert.ToChar(Convert.ToInt32(bit_array_to_byte(my_bit_array)));
|
||||
return Convert.ToString(my_char);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +109,27 @@ namespace KRY_0x02
|
|||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
// put
|
||||
if (pictureBox1.Image == null)
|
||||
{
|
||||
MessageBox.Show("you've nowhere to write to, boi");
|
||||
return;
|
||||
}
|
||||
do_a_stego do_A_Stego = new do_a_stego();
|
||||
Bitmap b = new Bitmap(pictureBox1.Image);
|
||||
string m = textBox1putm.Text;
|
||||
do_A_Stego.encode(b, m);
|
||||
}
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
// get
|
||||
if (pictureBox1.Image == null)
|
||||
{
|
||||
MessageBox.Show("you've nowhere to read from, boi");
|
||||
return;
|
||||
}
|
||||
do_a_stego do_A_Stego = new do_a_stego();
|
||||
Bitmap b = new Bitmap(pictureBox1.Image);
|
||||
textBox2getm.Text = do_A_Stego.gimme(b);
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,6 +151,7 @@ namespace KRY_0x02
|
|||
pictureBox1.Image = new Bitmap(dlg.FileName);
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
|
||||
textBox3.Text = dlg.FileName;
|
||||
path = textBox3.Text;
|
||||
im_h = pictureBox1.Image.Height;
|
||||
im_w = pictureBox1.Image.Width;
|
||||
textBox4height.Text = im_h.ToString();
|
||||
|
@ -101,6 +170,7 @@ namespace KRY_0x02
|
|||
label5pathtopic.Text = $"Security: Actual actual reality: nobody cares about his secrets."
|
||||
+ " (Also, I would be hard-pressed to find that wrench for $5.)";
|
||||
textBox3.Text = filename + "\t\t by randall ... https://xkcd.com/538";
|
||||
path = filename;
|
||||
im_h = pictureBox1.Image.Height;
|
||||
im_w = pictureBox1.Image.Width;
|
||||
textBox4height.Text = im_h.ToString();
|
||||
|
@ -114,6 +184,7 @@ namespace KRY_0x02
|
|||
label5pathtopic.Text = @"path/to/pic";
|
||||
pictureBox1.Image = null;
|
||||
textBox3.Text = "";
|
||||
path = "";
|
||||
textBox4height.Text = "";
|
||||
textBox5width.Text = "";
|
||||
textBox6capacity.Text = "";
|
||||
|
|
Loading…
Reference in New Issue