Bonjour

j'ai le code source ça marche bien mais je comprend pas le code source
SVP jai besoin d'aide
et merci d'avance :
Code : 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <windows.h>
 
#define TAILLE_MAX 500
 
void clean_stdin (void);
void pause (int); 
 
char *openfichier()
{
	static char str[2000] = "";
 
	FILE* fichier = NULL;
	char chaine[TAILLE_MAX] = "";
 
    fichier = fopen("readme.txt", "r");	
 
	if (fichier != NULL)
	{
		printf ("\n---== Texte a crypter ==---\n\n\n");
		while (fgets(chaine, TAILLE_MAX, fichier) != NULL) 
        {
			strcat(str, chaine);
            printf("%s", chaine); 
	    }
		printf ("\n\n\n---== Texte a crypter ==---");
        fclose(fichier); 
	}
	else
	{
		system("cls");
		printf("\n\nImpossible d'ouvrir le fichier readme.txt\n\n");
		pause (1);
		exit(EXIT_FAILURE);
	} 
	return str;
 
}
 
 
void cesar_crypt (int decallage, char *texte)
{
	char c;
	int decMin = decallage - 'a';
	decallage -= 'A';
	while(c = *texte) 
	{
		if(c > 'z') goto nextCHR;
		if(c < 'A') goto nextCHR;
		if(c <= 'Z') goto goMAJ;
		if(c < 'a') goto nextCHR;
		c = 'a' + (c + decMin) % 26;
		goto goREPLACE;
        goMAJ:
		c = 'A' + (c + decallage) % 26;
        goREPLACE: *texte = c;
        nextCHR: texte++;
  } 
}
 
int main(int argc, char *argv[])
{
	int menu = 0;
 
	printf("\n==== Menu ====\n\n\n");
	printf("1. Cryptage\n\n");
	printf("2. Decryptage\n\n");
	printf("3. Quitter\n\n\n");
	scanf("%d", &menu);
 
	printf("\n");	
 
	if (menu == 1)
	{
		int decalage;
		int crypter = 0;
 
		FILE* fichier = NULL;	
 
		char *texte;
		texte = openfichier();	
 
		system("cls");
		printf ("\n\nUtiliser un decallage de combien de lettres pour crypter ce fichier ?\n\n");
		scanf  ("%d", &decalage);
 
		printf ("\n\nVoulez-vous vraiment crypter ce texte en utilisant un decalage de %d lettres ?\n\n", decalage);
 
		printf ("Ecrivez 1 pour Oui ou 0 pour Non\n\n");
		scanf  ("%d", &crypter);
 
		if (crypter == 1)
		{
			system ("cls");		
			cesar_crypt (decalage, texte);
			printf ("\n---== Texte apres chiffrement ==---\n\n\n");
			printf ("%s\n", texte);
			printf ("\n\n---== Texte apres chiffrement ==---\n\n");
 
			fichier = fopen("readme.txt", "a+");
 
			if (fichier != NULL)
			{
				fprintf(fichier, "\n\nTexte Crypte : \n\n%s", texte);
				fclose(fichier); 
			}    
			pause (1);	 
		}
		else if (crypter == 0)
		{
			system ("cls");
			printf ("\nAu revoir, et bonne journee\n\n");
			pause (1);		
		}
		else if (crypter < 0 || crypter > 1)
		{
			printf ("\nVeuillez entrer 0 ou 1\n\n");
			scanf ("%d", &crypter);
 
			while (crypter < 0 || crypter > 1)
			{
				printf ("\nVeuillez entrer 0 ou 1\n\n");
				scanf ("%d", &crypter);
			}
 
			if (crypter == 1)
			{
				system ("cls");		
				cesar_crypt (3, texte);
				printf ("\n---== Texte apres chiffrement ==---\n\n\n");
				printf ("%s\n", texte);
				printf ("\n\n---== Texte apres chiffrement ==---\n\n");
 
				fichier = fopen("readme.txt", "a+");
 
				if (fichier != NULL)
				{
					fprintf(fichier, "\n\nTexte Crypte : \n\n%s", texte);
					fclose(fichier); 
				} 
				pause (1);	 
			}
			else if (crypter == 0)
			{
				system ("cls");
				printf ("\nAu revoir, et bonne journee\n\n");
				pause (1);			
			}
		}
	}
 
	if (menu == 2)
	{
		int decalage = 26 ;	
 
		FILE* fichier = NULL;	
 
		char *texte;
		texte = openfichier();
 
		while (decalage > 0)
		{
			cesar_crypt (decalage, texte);
 
			fichier = fopen("readme.txt", "a+");
			if (fichier != NULL)
			{
				fprintf(fichier, "\n\n%s", texte);
				fclose(fichier); 
			} 
			decalage--;		
		}
 
		system("cls");
		printf("\n\nDecryptage reussi, disponible dans le fichier readme.txt\n\n");
		pause(1);
	}
 
	if (menu == 3)
	{
		getchar();
	}
	if (menu > 3 || menu < 1)
	{
		exit(EXIT_FAILURE);
	}
}
 
void clean_stdin (void) 
{
    int c = 0;
    do
    {
      c = getchar();
    } 
	while (c != '\n' && c != EOF);
}
 
void pause (int b)
{
    printf ("\nAppuyez sur Entrer pour quitter\n");
    if (b==0)
        getchar ();
    else if (b==1)
    {
        clean_stdin ();
        getchar ();
    }
}
/*Merci a SoftEvans, Melem et Pouet_forever*/