Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- Stream input = null;
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- if ((input = openFileDialog1.OpenFile()) != null)
- {
- int p = 0;
- byte[] mass = File.ReadAllBytes(openFileDialog1.FileName);
- string rass = openFileDialog1.FileName.Substring(openFileDialog1.FileName.Length - 3);
- byte[] rasb = encode.GetBytes(rass);
- byte[] key = encode.GetBytes(textBox1.Text);
- byte[] fullkey = new byte[mass.Length];
- for (int i = 0; i < fullkey.Length; i++)
- {
- fullkey[i] = key[p];
- p++;
- if (p == key.Length)
- p = 0;
- }
- for (int i = 0; i < fullkey.Length; i++)
- {
- mass[i] = (byte)(mass[i] ^ fullkey[i]);
- }
- byte[] exemass = File.ReadAllBytes(Application.ExecutablePath);
- byte[] final = new byte[exemass.Length + mass.Length+3];
- for (int i = 0; i < exemass.Length; i++)
- {
- final[i] = exemass[i];
- }
- int k=0;
- for (int j = exemass.Length; j < exemass.Length + mass.Length; j++)
- {
- final[j] = mass[k];
- k++;
- }
- int l = 0;
- for (int m = exemass.Length + mass.Length; m < exemass.Length + mass.Length + 3; m++)
- {
- final[m] = rasb[l];
- l++;
- }
- File.WriteAllBytes(Application.StartupPath + "/Crypted.exe", final);
- MessageBox.Show("Success!");
- }
- }
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsDigit(e.KeyChar))
- {
- e.Handled = true;
- }
- button1.Enabled = true;
- byte[] exemass = File.ReadAllBytes(Application.ExecutablePath);
- if (exemass.Length > 11264)
- button2.Enabled = true;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- byte[] cryptedexe = File.ReadAllBytes(Application.ExecutablePath);
- byte[] dividedfile = new byte[cryptedexe.Length - 11267];
- byte[] rasb = new byte[3];
- int h=0;
- int p = 0;
- int g = 0;
- for (int i = 11264; i < cryptedexe.Length; i++)
- {
- if (i < (cryptedexe.Length - 3))
- {
- dividedfile[h] = cryptedexe[i];
- h++;
- }
- else
- {
- rasb[g] = cryptedexe[i];
- g++;
- }
- }
- string rass = encode.GetString(rasb);
- byte[] key = encode.GetBytes(textBox1.Text);
- byte[] fullkey = new byte[dividedfile.Length];
- for (int i = 0; i < fullkey.Length; i++)
- {
- fullkey[i] = key[p];
- p++;
- if (p == key.Length)
- p = 0;
- }
- for (int i = 0; i < fullkey.Length; i++)
- {
- dividedfile[i] = (byte)(dividedfile[i] ^ fullkey[i]);
- }
- File.WriteAllBytes(Application.StartupPath + "/decrypted."+rass, dividedfile);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement