Bonjour tous le monde , j'ai un petit problème : J'ai un programme en C# qui crypte un message dans une image. Pour le faire , j'ai changé le code couleur des premiers pixels de l'image en celui des codes ascii du textes. Le probleme est que j'arrive pas à récuperer par la suite le texte que j'ai crypté dans l'image ! cela me retourne rien du tout !! comme si les code couleur qui j'ai modifié précédemment nous pas été prise en compte or on peut voir sur l'image qu'elle l'ont été : voici le code si vous pouvez m'aider !! merci d'avance
Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
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 public void crypter(){ string text = textBox1.Text; int length = text.Length; Bitmap gray = new Bitmap(bmp.Width,bmp.Height, PixelFormat.Format16bppRgb555); Color pixel; for (int i = 0; i < bmp.Width; i++) { for (int j = 0; j < bmp.Height; j++) { pixel = bmp.GetPixel(i,j); int R = (int)pixel.R; int G = (int)pixel.G; int B = (int)pixel.B; gray.SetPixel(i, j, Color.FromArgb(R, G, B)); } } int R1 = length; gray.SetPixel(0,0, Color.FromArgb(R1, R1, R1)); int count = 0; for (int i = 0; i < length; i++) { R1 = (int)(text[i]); textBox1.Text += "" + R1 + " "; gray.SetPixel(count, i+1, Color.FromArgb(0,R1, R1, R1)); MessageBox.Show("" + gray.GetPixel(count, i+1)); count++; } gray.Save("a_crypt.png"); MessageBox.Show("Cryptage Effectué"); }
et voici le code de décryptage
Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
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 public void Decrypt(){ Color pixel; int count=0; bmp = new Bitmap("a_crypt.png"); pixel = bmp.GetPixel(0,0); int R = (int)pixel.R; int G = (int)pixel.G; int B = (int)pixel.B; int A = (int)pixel.A; string txt = ""; for (int i = 0; i < 20; i++) { pixel = bmp.GetPixel(count,i+1); MessageBox.Show("" + pixel); R = (int)pixel.R; G = (int)pixel.G; B = (int)pixel.B; A = (int)pixel.A; txt+=(char)(R); count++; } textBox1.Text = txt; MessageBox.Show("Decryptage Fini"); }
Partager