Not bothering to use ROT13, I just dropped that into my generic substitution cipher decoder and it spat out the answer almost immediately - quite pleased with that.
Not bothering to use ROT13, I just dropped that into my generic substitution cipher decoder and it spat out the answer almost immediately - quite pleased with that.
In short:
While True:
Generate a random key
"Decode"
Score
Start timer
While timer not expired:
Perturb the key
Score
If better:
Keep the new key
Reset timer
Print decrypt
In this case the first output was completely readable.I'd like to try my own hand at this, but the way I'm thinking of making the fitness function doesn't seem like it would be smooth enough.
What did you do?
So, let E(t) be the frequency of occurrence of the trigram t in English, d(t) be how often it occurs in the decrypted text, and compute:
Score = sum( [ E(t)*d(t) for t in decrypt ] )
If common trigrams turn up frequently in the decrypt, this will be "large". If uncommon trigrams turn up frequently, this will be "small".that is a really good idea...
Turns out there's also a fair amount of data to use as well.
http://www.cse.chalmers.se/edu/year/2010/course/TDA351/ass1/...
I was thinking too rigidly. Thanks!
My (admittedly naive) understanding of using RSS is this. I have a model of the data, which in this case will be expected frequencies of my n-grams. Then I compute the actual frequencies of the n-grams, take the difference, square the difference, and add up all the squares. A small number is then indicative of a good fit.
I don't see why this would be better. Not least, this has the problem of all those n-grams that don't turn up in my decrypt. I still have to square their expected frequency and add them into the sum. That contrasts with the method I'm using, where I just take the n-grams that do appear, multiply by the expected frequency, and add that into a running total.
So I guess I don't understand your suggestion.