typedef struct { // 퀴즈 JSON 데이터 형식에 맞춘 구조체
char question[100];
char options[4][50];
int answer;
} Quiz;
void decryptGPG(const char* encryptedFile, char** decryptedString) {
char command[256]; // GPG 복호화 시작
snprintf(command, sizeof(command), "gpg --batch --yes --decrypt %s", encryptedFile);
FILE* pipe = popen(command, "r");
if (!pipe) {
printf("GPG 복호화 명령을 실행하는 데 실패했습니다\n");
exit(1);
}
char buffer[1024]; // 파일 불러오기 시작
size_t totalSize = 0;
*decryptedString = NULL;
while (fgets(buffer, sizeof(buffer), pipe) != NULL) {
size_t len = strlen(buffer);
*decryptedString = (char*)realloc(*decryptedString, totalSize + len + 1);
strcpy(*decryptedString + totalSize, buffer);
totalSize += len;
}
pclose(pipe);
if (*decryptedString == NULL) {
printf("복호화가 실패했거나 빈 결과가 나왔습니다\n");
exit(1);
}
}