OTP tough nut

The fear of every surveillance society: citizens protecting their own privacy with strong cryptography

OTP tough nut

Post by tarantulas on Sun Aug 23, 2009 11:24 pm
([msg=28346]see OTP tough nut[/msg])

So, as a challenge I have several .jpgs and a text file encrypted with a one time pad. I've found the key and have written a C program to decrypt (basically a version of cat that XORs). When testing on the text file (easiest to see if things are working properly), the text seems decrypted (blocks of characters separated by a single space), but the characters themselves are crap (lots of umlauts). I've done lots of little tweaks and still no dice.
Code: Select all
#include <stdio.h>

void filecopy(FILE* , FILE*, FILE*);

int main(int argc, char* argv[]){

   FILE* fp;
   FILE* key;
   key = fopen("key.txt", "rb");
   if(argc == 1){
      filecopy(stdin, stdout, key);
      while(--argc > 0){
         if ((fp = fopen(*++argv, "rb")) == NULL){
            printf("krypt: problem\n");
            return 1;
            filecopy(fp, stdout, key);

return 0;

void filecopy(FILE* ifp, FILE* ofp, FILE* kfp){

   int c, n;

   while(((c = getc(ifp)) != EOF) && ((n = getc(kfp)) != EOF)){
      c = c ^ n;
      putc(c, ofp);

any obvious signs of "doing it wrong"?
User avatar
New User
New User
Posts: 22
Joined: Sun Aug 23, 2009 9:09 pm
Blog: View Blog (0)

Return to Crypto

Who is online

Users browsing this forum: No registered users and 0 guests