Presentation is loading. Please wait.

Presentation is loading. Please wait.

Autokey Cipher 자동키 암호 Department of Cyber Security / 20121820 박건주.

Similar presentations


Presentation on theme: "Autokey Cipher 자동키 암호 Department of Cyber Security / 20121820 박건주."— Presentation transcript:

1 Autokey Cipher 자동키 암호 Department of Cyber Security / 박건주

2 1) 자동키 암호(Autokey Cipher) H E L L O 평문 P 값 키수열 C 값 T L P W Z 암호문

3 2) 자동키 암호(Autokey Cipher) #include <stdio.h>
#include <string.h> void Autokey(char text[],int key); void AntiAutokey(char text[],int key); void main() { char text[100]; int key=0; int choice=0; printf("encryption(0) or decryption(1) : "); fflush(stdin); scanf("%d",&choice); printf("Enter text to be encrypted OR decryption : ");

4 2) 자동키 암호(Autokey Cipher) scanf("%s",text);
strupr(text); // 문자열에 있는 소문자를 대문자로 바꿔주는 함수 fflush(stdin); printf("KEY : "); scanf("%d",&key); if(choice==0) Autokey(text,key); else AntiAutokey(text,key); }

5 2) 자동키 암호(Autokey Cipher) void Autokey(char text[],int key) {
int temp=0,i=0,autokey=0; while(1) if(i>0) key=autokey; if((text[i]>='A')&&(text[i]<='Z')) autokey=text[i]-65; temp=text[i]-65; temp=(temp+key) %26; text[i]=temp+65; i++; } else break; printf("%s\n",text);

6 2) 자동키 암호(Autokey Cipher) void AntiAutokey(char text[],int key) {
int temp=0,i=0,autokey=0; while(1) if(i>0) key=autokey; if((text[i]>='A')&&(text[i]<='Z')) temp=text[i]-65; temp=(temp-key+26)%26; autokey=temp; text[i]=temp+65; i++; } else break; printf("%s\n",text);


Download ppt "Autokey Cipher 자동키 암호 Department of Cyber Security / 20121820 박건주."

Similar presentations


Ads by Google