private void DecryptLayer() { int k, j = 0; bool[] f = new bool[8]; bool[] r = new bool[8]; bool[] b = new bool[8]; bool[] g = new bool[8]; Color pixel = new Color(); byte rb, gb, bb, gb1; pixel = Decrypted_Bitmap.GetPixel(2, 0); rb = pixel.R; gb1 = pixel.G; bb = pixel.B; int pwdlength = rb; pixel = Decrypted_Bitmap.GetPixel(0, 0); rb = pixel.R; gb = pixel.G; bb = pixel.B; long FileSize = rb + gb * 256 + bb * 256 * 256 + gb1 * 256 * 256 * 256; pixel = Decrypted_Bitmap.GetPixel(1, 0); rb = pixel.R; gb = pixel.G; bb = pixel.B; long FileNameSize = rb + gb * 256 + bb * 256 * 256; byte[] ResFile = new byte[FileSize]; string ResFileName = ""; string ResPwd = ""; byte Virtual; //textBox1.Text = pwdlength.ToString(); for (k = 0; (k * 3) <= pwdlength; k++) { pixel = Decrypted_Bitmap.GetPixel(k + 3, 0); rb = pixel.R; gb = pixel.G; bb = pixel.B; ResPwd += (char)rb; ResPwd += (char)gb; ResPwd += (char)bb; } string respwd1 = ResPwd.Substring(0, pwdlength + 1); //textBox5.Text = respwd1; if (textBox7.Text.Equals(respwd1, StringComparison.OrdinalIgnoreCase)) { toolStripStatusLabel1.Text = "Please Wait.......Decrypting"; Application.DoEvents(); //Read file name: for (k = 1; k < Image_Height && (k - 1) * (Image_Width / 3) < FileNameSize; k++) { for (j = 0; j < (Image_Width / 3) * 3 && (k - 1) * (Image_Width / 3) + (j / 3) < FileNameSize; j++) { pixel = Decrypted_Bitmap.GetPixel(j, k); rb = pixel.R; gb = pixel.G; bb = pixel.B; ToBoolean(rb, ref r); ToBoolean(gb, ref b); ToBoolean(bb, ref g); if (j % 3 == 0) { f[0] = r[7]; f[1] = b[7]; f[2] = g[7]; } else if (j % 3 == 1) { f[3] = r[7]; f[4] = b[7]; f[5] = g[7]; } else { f[6] = r[7]; f[7] = b[7]; Virtual = ToBytes(f); ResFileName += (char)Virtual; } } } //After file name read file on layer eight : int JTemp = j; k = 1; for (; k < Image_Height && (k - 1) * (Image_Width / 3) < FileSize + FileNameSize; k++) { for (j = 0; j < (Image_Width / 3) * 3 && (k - 1) * (Image_Width / 3) + (j / 3) < ((Image_Height - 1) * (Image_Width / 3) * 3) / 3 - 1 && (k - 1) * (Image_Width / 3) + (j / 3) < FileSize + FileNameSize; j++) { if (JTemp != 0) { j = JTemp; JTemp = 0; } pixel = Decrypted_Bitmap.GetPixel(j, k); rb = pixel.R; gb = pixel.G; bb = pixel.B; ToBoolean(rb, ref r); ToBoolean(gb, ref b); ToBoolean(bb, ref g); if (j % 3 == 0) { f[0] = r[7]; f[1] = b[7]; f[2] = g[7]; } else if (j % 3 == 1) { f[3] = r[7]; f[4] = b[7]; f[5] = g[7]; } else { f[6] = r[7]; f[7] = b[7]; Virtual = ToBytes(f); ResFile[(k - 1) * (Image_Width / 3) + j / 3 - FileNameSize] = Virtual; } } } //Read Bytes on remaining layer: long filebytesonlayer8 = ((Image_Height - 1) * (Image_Width / 3) * 3) / 3 - FileNameSize - 1; for (int layer = 6; layer >= 0 && filebytesonlayer8 + (6 - layer) * (((Image_Height - 1) * (Image_Width / 3) * 3) / 3 - 1) < FileSize; layer--) { for (k = 1; k < Image_Height && (k - 1) * (Image_Width / 3) + filebytesonlayer8 + (6 - layer) * (((Image_Height - 1) * (Image_Width / 3) * 3) / 3 - 1) < FileSize; k++) { for (j = 0; j < (Image_Width / 3) * 3 && (k - 1) * (Image_Width / 3) + (j / 3) + filebytesonlayer8 + (6 - layer) * (((Image_Height - 1) * (Image_Width / 3) * 3) / 3 - 1) < FileSize; j++) { pixel = Decrypted_Bitmap.GetPixel(j, k); rb = pixel.R; gb = pixel.G; bb = pixel.B; ToBoolean(rb, ref r); ToBoolean(gb, ref b); ToBoolean(bb, ref g); if (j % 3 == 0) { f[0] = r[layer]; f[1] = b[layer]; f[2] = g[layer]; } else if (j % 3 == 1) { f[3] = r[layer]; f[4] = b[layer]; f[5] = g[layer]; } else { f[6] = r[layer]; f[7] = b[layer]; Virtual = ToBytes(f); ResFile[(k - 1) * (Image_Width / 3) + j / 3 + (6 - layer) * (((Image_Height - 1) * (Image_Width / 3) * 3) / 3 - 1) + filebytesonlayer8] = Virtual; } } } } if (File.Exists(PathOfDSaveFile + "\\" + ResFileName)) { MessageBox.Show("File \"" + ResFileName + "\" Name already exists write another name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } else { File.WriteAllBytes(PathOfDSaveFile + "\\" + ResFileName, ResFile); } toolStripStatusLabel1.Text = "Decreption Sucessfully done"; Application.DoEvents(); } else { MessageBox.Show("Enter Correct Password", "Invalid Password!!"); } /**/ }
private void DecryptLayer() { MessageBox.Show("Please Wait.......", "Decrypting"); Application.DoEvents(); int k, j = 0; bool[] f = new bool[8]; bool[] r = new bool[8]; bool[] b = new bool[8]; bool[] g = new bool[8]; Color pixel = new Color(); byte rb, gb, bb; pixel = Decrypted_Bitmap.GetPixel(2, 0); rb = pixel.R; gb = pixel.G; bb = pixel.B; long pwdlength = rb + gb * 255 + bb * 255 * 255; pixel = Decrypted_Bitmap.GetPixel(0, 0); rb = pixel.R; gb = pixel.G; bb = pixel.B; long FileSize = rb + gb * 255 + bb * 255 * 255; pixel = Decrypted_Bitmap.GetPixel(1, 0); rb = pixel.R; gb = pixel.G; bb = pixel.B; long FileNameSize = rb + gb * 255 + bb * 255 * 255; byte[] ResFile = new byte[FileSize]; string ResFileName = ""; string ResPwd = ""; byte Virtual; for (k = 0; (k * 3) < pwdlength; k++) { pixel = Decrypted_Bitmap.GetPixel(k + 3, 0); rb = pixel.R; gb = pixel.G; bb = pixel.B; ResPwd += (char)rb; ResPwd += (char)gb; ResPwd += (char)bb; } textBox7.Text = ResPwd; /* * if (textBox7.Text.Equals(ResPwd, StringComparison.Ordinal)) * { * //Read file name: * for (k = 1; k < Image_Height && (k - 1) * (Image_Width / 3) < FileNameSize; k++) * for (j = 0; j < (Image_Width / 3) * 3 && (k - 1) * (Image_Width / 3) + (j / 3) < FileNameSize; j++) * { * pixel = Decrypted_Bitmap.GetPixel(j, k); * rb = pixel.R; * gb = pixel.G; * bb = pixel.B; * BytesToBoolean(rb, ref r); * BytesToBoolean(gb, ref b); * BytesToBoolean(bb, ref g); * if (j % 3 == 0) * { * f[0] = r[7]; * f[1] = b[7]; * f[2] = g[7]; * } * else if (j % 3 == 1) * { * f[3] = r[7]; * f[4] = b[7]; * f[5] = g[7]; * } * else * { * f[6] = r[7]; * f[7] = b[7]; * Virtual = BooleanToBytes(f); * ResFileName += (char)Virtual; * } * } * * //After file name read file on layer eight : * int JTemp = j; * k--; * * for (; k < Image_Height && (k - 1) * (Image_Width / 3) < FileSize + FileNameSize; k++) * for (j = 0; j < (Image_Width / 3) * 3 && (k - 1) * (Image_Width / 3) + (j / 3) < (Image_Height * (Image_Width / 3) * 3) / 3 - 1 && (k - 1) * (Image_Width / 3) + (j / 3) < FileSize + FileNameSize; j++) * { * if (JTemp != 0) * { * j = JTemp; * JTemp = 0; * } * pixel = Decrypted_Bitmap.GetPixel(j, k); * rb = pixel.R; * gb = pixel.G; * bb = pixel.B; * BytesToBoolean(rb, ref r); * BytesToBoolean(gb, ref b); * BytesToBoolean(bb, ref g); * if (j % 3 == 0) * { * f[0] = r[7]; * f[1] = b[7]; * f[2] = g[7]; * } * else if (j % 3 == 1) * { * f[3] = r[7]; * f[4] = b[7]; * f[5] = g[7]; * } * else * { * f[6] = r[7]; * f[7] = b[7]; * Virtual = BooleanToBytes(f); * ResFile[(k - 1) * (Image_Width / 3) + j / 3 - FileNameSize] = Virtual; * } * } * * //Read Bytes on remaining layer: * long filebytesonlayer8 = (Image_Height * (Image_Width / 3) * 3) / 3 - FileNameSize - 1; * * for (int layer = 6; layer >= 0 && filebytesonlayer8 + (6 - layer) * ((Image_Height * (Image_Width / 3) * 3) / 3 - 1) < FileSize; layer--) * for (k = 1; k < Image_Height && (k - 1) * (Image_Width / 3) + filebytesonlayer8 + (6 - layer) * ((Image_Height * (Image_Width / 3) * 3) / 3 - 1) < FileSize; k++) * for (j = 0; j < (Image_Width / 3) * 3 && (k - 1) * (Image_Width / 3) + (j / 3) + filebytesonlayer8 + (6 - layer) * ((Image_Height * (Image_Width / 3) * 3) / 3 - 1) < FileSize; j++) * { * pixel = Decrypted_Bitmap.GetPixel(j, k); * rb = pixel.R; * gb = pixel.G; * bb = pixel.B; * BytesToBoolean(rb, ref r); * BytesToBoolean(gb, ref b); * BytesToBoolean(bb, ref g); * if (j % 3 == 0) * { * f[0] = r[layer]; * f[1] = b[layer]; * f[2] = g[layer]; * } * else if (j % 3 == 1) * { * f[3] = r[layer]; * f[4] = b[layer]; * f[5] = g[layer]; * } * else * { * f[6] = r[layer]; * f[7] = b[layer]; * Virtual = BooleanToBytes(f); * ResFile[(k - 1) * (Image_Width / 3) + j / 3 + (6 - layer) * ((Image_Height * (Image_Width / 3) * 3) / 3 - 1) + filebytesonlayer8] = Virtual; * } * } * * if (File.Exists(PathOfDSaveFile + "\\" + ResFileName)) * { * MessageBox.Show("File \"" + ResFileName + "\" Name already exists write another name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, * MessageBoxDefaultButton.Button1); * return; * } * else * File.WriteAllBytes(PathOfDSaveFile + "\\" + ResFileName, ResFile); * MessageBox.Show("Done", "Decryption"); * Application.DoEvents(); * } * else * { * MessageBox.Show("Enter Correct Password","Invalid Password!!"); * }*/ }