sch9_ctf_3/tasks/Возвращение зашифрованного файла/Исходники/decrypt_file.cpp

33 lines
621 B
C++
Raw Permalink Normal View History

#include <stdio.h>
#include <stdlib.h>
const int maxsize = 33;
char line[maxsize+1];
char ans[maxsize+1];
FILE * file;
void copying() {
for (int i = 0; i < maxsize; ++i) {
ans[i] = line[i];
}
}
void decryption() {
for (int i = 0; i < maxsize; i+=1, ans[i] = (ans[i] ^ '^'-'|'+'&') - i) {
}
}
int main(int argc, char * argv[]) {
file = fopen("flag.enc", "r");
if (file == NULL)
printf("File does not exist!\n");
else {
fgets(line, maxsize+1, file);
copying();
decryption();
printf("%s\n", ans);
fclose(file);
}
return 0;
}