-
-
Save tkdgma0724/1875c140a99001ad40b2b1bd6c9af1b1 to your computer and use it in GitHub Desktop.
파일 암,복호화
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <Windows.h> | |
void Menu(); | |
void FileEncoding(); | |
void FileDecoding(); | |
void main() | |
{ | |
Menu(); | |
} | |
void Menu() | |
{ | |
int choice; | |
for (;;)// MENU 창 출력 및 입력 // | |
{ | |
printf("1. 파일 암호화\n2. 파일 복호화\n3. 종료\n\n"); | |
printf("입력 : "); | |
scanf("%d", &choice); | |
if (choice<=2) | |
{ | |
break; | |
} | |
else if (choice ==3) | |
{ | |
printf(" 프로그램을 종료합니다. "); | |
break; | |
} | |
else | |
{ | |
continue; | |
} | |
} | |
switch (choice)// 암호화 할지 복호화 할지 종료할지 선택// | |
{ | |
case 1: | |
FileEncoding(); | |
break; | |
case 2: | |
FileDecoding(); | |
break; | |
case 3: | |
exit(1); | |
} | |
} | |
void FileEncoding()// 암호화 할 파일명 입력 // | |
{ | |
FILE * FileCreat = NULL; | |
int File; | |
char Type[27]; | |
system("cls"); | |
printf("확장자까지 입력하여 주십시오.\n"); | |
getchar(); | |
for (;;) | |
{ | |
printf("암호화 할 파일을 입력 해 주십시오 : "); | |
gets(Type); | |
FileCreat = fopen(Type, "rb"); | |
if (FileCreat == NULL) | |
{ | |
printf("\n파일이 존재하지 않습니다.\n"); | |
continue; | |
} | |
else// 암호화 후 파일생성(XOR 연산 후)// | |
{ | |
FILE * CreatFile; | |
char NameType[27]; | |
printf("\n생성 될 파일명을 적어주세요 : "); | |
gets(NameType); | |
CreatFile = fopen(NameType, "wb"); | |
while ((File = fgetc(FileCreat)) != EOF) | |
{ | |
File ^= 13; | |
printf("."); | |
fputc(File, CreatFile); | |
} | |
fclose(CreatFile); | |
printf("\n\n암호화 완료! 프로그램을 종료 합니다\n"); | |
break; | |
} | |
} | |
fclose(FileCreat); | |
} | |
void FileDecoding()//복호화 할 파일명 입력// | |
{ | |
FILE * DeCodFileCreat = NULL; | |
int File; | |
char DeType[27]; | |
system("cls"); | |
printf("확장자명 까지 입력하십시오.\n"); | |
getchar(); | |
for (;;) | |
{ | |
printf("복호화 할 파일을 입력 해 주십시오 : "); | |
gets(DeType); | |
DeCodFileCreat = fopen(DeType, "rb"); | |
if (DeCodFileCreat == NULL) | |
{ | |
printf("\n파일이 존재하지 않습니다.\n"); | |
continue; | |
} | |
else// 복호화 후 생성될 파일 입력 (XOR 연산후)// | |
{ | |
FILE * DeCodCreatFile; | |
char DeCodNameType[27]; | |
printf("\n생성 될 파일명을 적어주세요 : "); | |
gets(DeCodNameType); | |
DeCodCreatFile = fopen(DeCodNameType, "wb"); | |
while ((File = fgetc(DeCodFileCreat)) != EOF) | |
{ | |
File ^= 13; | |
printf("."); | |
fputc(File, DeCodCreatFile); | |
} | |
fclose(DeCodCreatFile); | |
printf("\n\n복호화 완료! 프로그램을 종료 합니다\n"); | |
break; | |
} | |
} | |
fclose(DeCodFileCreat); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment