Guest User

Untitled

a guest
Nov 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <stdio.h>#include <string.h>#include <stdlib.h> void xor(char *str, int len){ int cipher; int key; int bound = len / 2;  //str[bound] 부터는 CipherText 시작 for (int j = 0; j < len; j++) //배열의 모든 원소를 계산가능한 숫자로 치환 {  if ('a' <= str[j] && str[j] <= 'f')   str[j] = str[j] - 'a' + 10;  else if ('0' <= str[j] && str[j] <= '9')   str[j] = str[j] - '0'; } for (int i = 0; i < bound; i += 2) {  cipher = str[bound + i] * 16 + str[bound + i + 1];  key = str[bound - i - 2] * 16 + str[bound - i - 1];  printf("%c", key ^ cipher); }
  2. }
  3. int main(void){ FILE *fp; int temp; char str[10000]; fp = fopen("Ciphers.txt", "r");
  4.  while (1) {  temp = fscanf(fp, "%s", str);  if (temp != 1)   break;  else if (str[0] == '[')   continue;  //printf("%s\n", str); //print encryption result : enckey + cipherText
  5.   xor(str, strlen(str)); //print plain text    printf("\n");   } fclose(fp); return 0;}
  6. /*[{'9','d','b','d','7','4',......}->{9,13,11,13,7,4,....}*/
Add Comment
Please, Sign In to add comment