Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "string.h"
  3. int main(int argc, char *argv[]) {
  4. FILE *file =fopen("file", "r");
  5. FILE *szyfr_file;
  6. printf(argv[1]);
  7. char *haslo;
  8. scanf("%s",haslo);
  9. int znak;
  10. char tymczasowy[6];
  11. tmpnam(tymczasowy);
  12. char *tymczasowyptr;
  13. strcpy(tymczasowy,tymczasowyptr);
  14. if (NULL==(szyfr_file=fopen(tymczasowy,"wb"))) return 2;
  15. if (NULL==(file=fopen(argv[1],"rb"))) return 1;
  16. for (int j =0 ;znak != EOF;j++){
  17. znak = fgetc(file);
  18. int zaszyfrowany_znak =znak ^ haslo[ j % (strlen(haslo)) ];
  19. fputc(zaszyfrowany_znak,szyfr_file);
  20. }
  21. fclose(file);
  22. fclose(szyfr_file);
  23. unlink(argv[1]);
  24. rename(tymczasowyptr,argv[1]);
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement