Welcome Guest [Log In] [Register]
Viewing Single Post From: *echo* *echo*
Revelation
Member Avatar
Administrator
[ *  *  *  *  * ]
Okay, I wrote a nice little program to convert this into a more workable form:

Code:
 

#include "stdafx.h"
#include <string.h>

#define NUMBOFINTSFORONECHAR 5

struct NUMBANDALPHA
{
char numbseq[NUMBOFINTSFORONECHAR]; // number sequence
char alpha; // alphabetic representative
};

int _tmain(int argc, _TCHAR* argv[])
{
char buffer[1000];
NUMBANDALPHA sequences[200];
char finalstring[200];

char newalphachar = 'A';
int seqlength = 0;
int finstringpos = 0;

FILE* a = fopen("cipher.txt", "rt");

if (!a)
 return 1;

int bufpos = 0;
while(!feof(a)) // read the file
{
 char ch = getc(a);
 if (ch >= '0' && ch <= '9') // only numbers
 {
  buffer[bufpos] = ch;
  bufpos++;
 }
}
buffer[bufpos] = 0;

fclose(a);

if (bufpos %  NUMBOFINTSFORONECHAR != 0)
{
 printf("Error: this number is wrong.\n");
 return 2;
}

for (int i = 0; i < bufpos; i += NUMBOFINTSFORONECHAR) // convert to alpha
{
 char curseq[NUMBOFINTSFORONECHAR];
 strncpy(curseq, buffer + i, NUMBOFINTSFORONECHAR);

 bool found = false;
 for (int j = 0; j < seqlength; j++) // check if the sequence already exists
 {
  if (strncmp(curseq, sequences[j].numbseq, NUMBOFINTSFORONECHAR) == 0)
  {
   finalstring[finstringpos] = sequences[j].alpha;
   finstringpos++;
   found = true;
   break;
  }
 }

 if (!found)// a new sequence is found, generate a new ascii value
 {
  strncpy(sequences[seqlength].numbseq, curseq, NUMBOFINTSFORONECHAR);
  sequences[seqlength].alpha = newalphachar;
  newalphachar++;
 
  finalstring[finstringpos] = sequences[seqlength].alpha;
  finstringpos++;
  seqlength++;
 }
}

finalstring[finstringpos] = 0;
printf(finalstring);

FILE * b = fopen("output.txt", "wt");
fprintf(b, finalstring);
fclose(b);

getchar();
return 0;
}



These are my results(hidden)
ABCDCEDCFGHBGIAIJBCFKGLMNCKGLDCMCEMABCDCIFGEOACDPNOCQCGQPCJBGRPENSABCKREFICCHBGIAIEDCTLIAPGGUNFHOGDEAACFANGFQCGQPCJBGVCPNCWCNFDCNFREDFEANGFEDCTLIAQGIAQGFNFHABCNDPNWCIRBLRUQEPEBFNLU

Now it's a nice mono sub :)
RRRREJMEEEEEPVKLWENFNVJKEEEEEAOLKAFKLXCFZAASDJXZTTTTTTTLSIOWJXMOKLAFJNNKFNXN
RAGRBAQEMHIGDJVDSEOXVIYCELFHWLELJFIENXLRATALSJFSLCYTKLASJDKMHGOVOKAJDNMNUITN
RRRRLJVEEEEECLYVYHNVPFTAEEEEEMWLMEIRNGLARWJAKJDFLWNTIERJMIPQWOTZEOCXKNUBNXCN
RJIRPOWEANFUSNCZVDVZNMSFEKLOEPZLDKDJWSAAAAAAAOERHJCTNCKFRIMVKSOFOMKMANREWNBN
RZUDRGXEEEEENFQIDVLQNCKNEEEEEDGLLLLLLAWIOSNCDARLODMTOEJXMILDFJROTKJSDNLVCZNN
Offline Profile Quote Post
*echo* *echo* · Challenges