//============================================================================ // Author : SaEeD // Description : Vernam Decryptor Example // // *****PLEASE DOWNLOAD CIPHER AND PAD FILE TO USE THIS APPLICATION ***** //============================================================================ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc,char *argv[]) { FILE *cipherFile,*padFile; char buf; int byte1,byte2; if(argc != 3){ fprintf(stderr,"Usage: %s <Cipher File> <Pad File>\n",argv[0]); return 1; } if((cipherFile=fopen(argv[1],"r")) ==NULL){ fprintf(stderr,"[!]Cannot Open Cipher File.\n"); return 1; } printf("[+]Reading Cipher File: %s\n",argv[1]); if((padFile = fopen(argv[2],"r")) == NULL){ fprintf(stderr,"[!]Cannot Open Pad File.\n"); return 0; } printf("[+]Reading Pad File: %s\n",argv[2]); printf("[+]Decrypted Message is: \""); while (byte1 != EOF) { byte1 = fgetc(cipherFile); byte2 = fgetc(padFile); if(byte1 == EOF) break; // printf("Byte in hex: 0x%x\n",byte1); buf = byte1 ^ byte2; printf("%c",buf); } printf("\"\n[-]Program Terminating...\n"); fclose(cipherFile); fclose(padFile); return 0; }