#include #include #include int main(int argc, char *argv[]) { if (argc != 2) { printf("Podano złą liczbę argumentów!"); return 0; } char haslo[20]; printf("Podaj hasło (max 20 znaków): "); fgets(haslo, sizeof(haslo), stdin); char tymczasowy[] = "./tmp_XXXXXX"; mkstemp(tymczasowy); FILE *file1; FILE *file2; if (NULL == (file1 = fopen(argv[1], "rb"))) return 1; if (NULL == (file2 = fopen(tymczasowy, "wb"))) return 1; int j = 0; int znak; while ((znak = getc(file1)) != EOF) { znak ^= haslo[j++ % strlen(haslo) - 1]; putc(znak, file2); } rename(tymczasowy, argv[1]); fclose(file1); fclose(file2); }