salut
dans la cryptographie RSA,je veux modifier la structure de fonction par remplacement '' d'ouvrir et d'enregsitre dans un fichier '' dans un parmetre fixe.
au lieu d'ecrire FILE *msg, *msg1, *interm1 ;par string interm1 msg,msg
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
FILE *msg, *msg1, *interm1;
void Rsa::algoComplet( )
{
	clock_t t1, t2;
 
	t1 = clock();
	//initCle();
	hachage();
initCle();
interm1=fopen("interm1.cry" , "wb");
	if(interm1==NULL)
	{
   	printf("Impossible d'ouvrir le fichier resultat.\n");
   }
	interm=fopen("interm.txt" , "rb");
	if(interm==NULL)
	{
   	printf("Impossible d'ouvrir le fichier resultat.\n");
   }
//crypter();
 
msg=fopen("message.txt" , "w");
fwrite(&message,10*sizeof(unsigned  char),1,msg);
fclose(msg);
msg=fopen("message.txt" , "r");
msg1=fopen("message.cry" , "wb");
	if(msg1==NULL)
	{
   	printf("Impossible d'ouvrir le fichier resultat.\n");
   }
crypter();
fclose(interm);
	fclose(interm1);
		fclose(msg);
	fclose(msg1);
t2 = clock();
	printf("\n\n\n\n\n\n\n\n\n\nLe cryptage de votre fichier est termine.");
   printf("\n\nvotre fichier crypter se nomme result.cry");
   printf("\n\n\n\n\n\n\n\n\n\nLe temps de calcul = %f\n", (float)(t2-t1)/CLOCKS_PER_SEC);
   system("PAUSE");
	getch();
 
}
/***************************MENU CRYPTOGRAPHIE*********************************/
 
/*******************************CRYPTER****************************************/
void Rsa:: crypter()
{
        unsigned char c;
	unsigned long int i=0;
	unsigned long int k;
	char nom_fichier[20];
printf("\n\n\t\t\t   	*********\n");
   printf("\t\t\t     	*CRYPTER*\n");
printf("\t\t\t     	*********\n\n\n\n");
   fflush(stdin);
   //clrscr();
   printf("\n\n\t\tATTENDEZ SVP PENDANT LE CRYPTAGE.");
	while((feof(interm)==0) && (fread(&c,sizeof(unsigned char),1,interm)!=0))
  	{
		printf("le caractère est %c\n", c);
  	   fseek(interm,sizeof(unsigned char)*i,SEEK_SET);
     	fread(&c,sizeof(unsigned char),1,interm);//interm:le fichier qui contient les données sources claires
   	k=crypt(c,n,e);
  fwrite(&k,sizeof(unsigned long int),1,interm1);// interm1: le fichier qui contient les données chiffres
	i=i+1;
   }
	i = 0;
printf("\n\n\t\tATTENDEZ SVP PENDANT LE CRYPTAGE.");
	while((feof(msg)==0) && (fread(&c,sizeof(unsigned char),1,msg)!=0))
  	{
		printf("le caractère est %c\n", c);
  	   fseek(msg,sizeof(unsigned char)*i,SEEK_SET);
     	fread(&c,sizeof(unsigned char),1,msg);
   	k=crypt(c,n,e);
  fwrite(&k,sizeof(unsigned long int),1,msg1);
	i=i+1;
   }	
}