Difference between revisions of "Brion Cipher"

From Clan Lord Spoilers
Jump to navigation Jump to search
m (Added to quest solutions)
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
Borrowing from [http://red-quill.org/babajaga/library/brions/tharloch.html Tharloch] we know the base cypher (remove spaces, rotate letters backwards by their position [counting from 1 after spaces are removed] in the message).  The issue then becomes that this method does not work for the later messages.
 
Borrowing from [http://red-quill.org/babajaga/library/brions/tharloch.html Tharloch] we know the base cypher (remove spaces, rotate letters backwards by their position [counting from 1 after spaces are removed] in the message).  The issue then becomes that this method does not work for the later messages.
  
The solution is then to brute force all 26 possible starting rotations, as any others are redundant.  To acomplish this, I borrowed heavily from [http://www.cs.utk.edu/~cjohnson/computing/rot13.c an implimentation of rot13] in C, but generalized to try all possible initial rotations and changed to backwards rotate by the character's index.  The program reads from 'libraries.txt', which needs to be in the same directory as the program, and the spaces removed from the 'libraries.txt' file before running the program.  It then outputs all possible translations of each line of the message, as well as the 'key' for that line.  That is the index of the first character to create that particular message.  All you have to do is look through the output for something that looks english.
+
The solution is then to brute force all 26 possible starting rotations, as any others are redundant.  To acomplish this, I borrowed heavily from [http://www.cs.utk.edu/~cjohnson/computing/rot13.c an implementation of rot13] in C, but generalized to try all possible initial rotations and changed to backwards rotate by the character's index.  The program reads from 'libraries.txt', which needs to be in the same directory as the program, and the spaces removed from the 'libraries.txt' file before running the program.  It then outputs all possible translations of each line of the message, as well as the 'key' for that line.  That is the index of the first character to create that particular message.  All you have to do is look through the output for something that looks English.
  
 
<pre>
 
<pre>

Latest revision as of 02:34, 22 February 2008

Thought Process

Borrowing from Tharloch we know the base cypher (remove spaces, rotate letters backwards by their position [counting from 1 after spaces are removed] in the message). The issue then becomes that this method does not work for the later messages.

The solution is then to brute force all 26 possible starting rotations, as any others are redundant. To acomplish this, I borrowed heavily from an implementation of rot13 in C, but generalized to try all possible initial rotations and changed to backwards rotate by the character's index. The program reads from 'libraries.txt', which needs to be in the same directory as the program, and the spaces removed from the 'libraries.txt' file before running the program. It then outputs all possible translations of each line of the message, as well as the 'key' for that line. That is the index of the first character to create that particular message. All you have to do is look through the output for something that looks English.

#include <stdio.h>
// Brion Message brute forcer, by Phroon.

int main(void)
{
	int i,j;
	FILE *fp;
	char ch;
	
	for (j=0;j<26;j++){
		
		fp = fopen("libraries.txt","r");
		
		i = j;
		printf("%d:",j);
		while (fscanf(fp,"%c",&ch) != EOF) {
			if (ch >= 'a' && ch <= 'z') {
				ch = ch - i%26;
				
				if (ch < 'a')
					ch = ch + 26;
			} else if (ch >= 'A' && ch <= 'Z') {
				ch = ch - i%26;
				
				if (ch < 'A')
					ch = ch + 26;
			}
			
			i++;
			if(ch=='\n') i=j;
			printf("%c",ch);
		}
	}
	return 0;
}