Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void cript_decript(char *clef,char *fichierIN,char *fichierOUT)
- {
- FILE *f_in;
- FILE *f_out;
- f_in = fopen(fichierIN,"r") ;
- if (f_in == NULL)
- {
- fprintf(stderr, "\n Erreur : Impossible de lire le fichier %s\n","fichierIN") ;
- exit(EXIT_FAILURE) ;
- }
- f_out = fopen(fichierOUT,"w") ;
- if (f_out == NULL)
- {
- fprintf(stderr, "\n Erreur : Impossible d’ecrire dans le fichier %s\n","fichierOUT") ;
- exit(EXIT_FAILURE) ;
- }
- int i=0;
- do
- {
- char u;
- char c = fgetc(f_in) ;
- if (clef[i] == '\0') i=0;
- char b;
- b= clef[i];
- u = c^b;
- i++;
- if (!feof(f_in)) fputc(u, f_out) ;
- }
- while (!feof(f_in)) ;
- fclose(f_in) ;
- fclose(f_out) ;
- }
Add Comment
Please, Sign In to add comment