Hidden Message? not really, just encoded

Today I read a post in Damog’s blog where he gave a nice PERL tip based in a “hidden message”. Even when some people might argue that the message is really hidden, to me it seems like it is simply encoded, that’s not the same, is it?

In anycase, if some of you were lazy enough to not decode the message here is a program that does just that:


#include <stdio.h>
#include <stdlib.h>

#include <string.h>

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

  FILE *handle;
  char char_byte[9], *c;

  long binval;
  if ( argc < 2 ) { 
    return -1;  
  }     
  handle = fopen(argv[1], "r"); 
  if ( NULL == handle ) {

    perror("error");
    return -1;  
  }     
  memset(char_byte, '0', sizeof(char_byte) - 1); 
  char_byte[8] = 0;

  c = char_byte;
  while ( 0 != fread(c, 1, 1, handle) ) {

    if ( *c != '1' && *c != '0' ) {

      continue;
    }
    if ( !*(c + 1) ) {
      binval = strtol(char_byte, NULL, 2);

      printf("%c", binval);
      c = char_byte;

      continue;
    }
    c++;
  }     
  printf("\\n");
  fclose(handle);

  return 0;
}

1. Copy and paste the program.
2. Copy and paste the encoded message in Damog’s post or the other post he mentioned.
3. gcc readasbin.c -o readasbin.exe
4. ./readbin.exe message.txt

Jeez … I should have used PERL 🙂

This entry was posted in boring, C/C++. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*