Skip to content

Write a program to solve any letter substitution cipher automatically

Notifications You must be signed in to change notification settings

avocadorice/cipher-solver

Repository files navigation

Usage: python unscramble.py <ciphertext-input-file> <dictionary-input-file>

Note: use the already provided words-sorted-by-pattern file, which is presorted by letter pattern and word frequencies.

Example 1:

user$ cat ciphertext-mod
MGG MGSDZ ULC RMUBLUSRCO AOKDBC HCAU ULC TKCR
RLKGC MGG ULC RSFMD BMFC MDV RCDU NMOCXSSU ICOTMDU USS
SYUIKVC KD ULC VKIUMDBC M RKGVBMU VKV ZOSRG

user$ python unscramble.py ciphertext-mod words-sorted-by-pattern
Score: 84
ALL ALONG THE WATCHTOWER PRINCE KEPT THE VIEW WHILE ALL THE WOMAN CAME AND WENT BAREFOOT SERVANT TOO OUTSIDE IN THE DISTANCE A WILDCAT DID GROWL TWO RIDER WERE APPROACHING THE WIND BEGIN TO HOWL

Example 2:

user$ cat ciphertext2-mod
ISRR ESBYECQ UQT DS DQX Q ARBBXL GBUS
ISRWQYS XSNQYJTSGJ JDSL IBMRXGJ ECKS DCT GB ZRBJDSU
DS QUFSX NBBY DBIQYX IDSYS ZQG C EB
DBIQYX UQCX JDSYSU BGRL BGS NRQZS C FGBI
UQT UQCX JSRR TS HMCZF TQG C EBJ JB YMG
BR DBIQYX VMUJ NBCGJSX ICJD DCU EM


user$ python unscramble.py ciphertext2-mod words-sorted-by-pattern
Score: 113
TELL GEORGIA SAM HE HAD A BLOODY NOSE TELAARE DEPARTMENT THEY TOULDNT GIBE HIM NO CLOTHES HE ASKED POOR HOTARD THERE CAN I GO HOTARD SAID THERES ONLY ONE PLACE I KNOT SAM SAID TELL ME QUICK MAN I GOT TO RUN OL HOTARD CUST POINTED TITH HIS GUN AND SAID THAT TAY DOTN ON HIGHTAY
Score: 113
TELL GEORGIA SAM HE HAD A FLOODY NOSE TELAARE DEPARTMENT THEY TOULDNT GIBE HIM NO CLOTHES HE ASKED POOR HOTARD THERE CAN I GO HOTARD SAID THERES ONLY ONE PLACE I KNOT SAM SAID TELL ME QUICK MAN I GOT TO RUN OL HOTARD CUST POINTED TITH HIS GUN AND SAID THAT TAY DOTN ON HIGHTAY
Score: 103
BELL GEORGIA SAM HE HAD A BLOODY NOSE BELAARE DEPARTMENT THEY BOULDNT GIBE HIM NO CLOTHES HE ASKED POOR HOBARD BHERE CAN I GO HOBARD SAID THERES ONLY ONE PLACE I KNOB SAM SAID TELL ME QUICK MAN I GOT TO RUN OL HOBARD CUST POINTED BITH HIS GUN AND SAID THAT BAY DOBN ON HIGHBAY
Score: 103
BELL GEORGIA SAM HE HAD A FLOODY NOSE BELAARE DEPARTMENT THEY BOULDNT GIBE HIM NO CLOTHES HE ASKED POOR HOBARD BHERE CAN I GO HOBARD SAID THERES ONLY ONE PLACE I KNOB SAM SAID TELL ME QUICK MAN I GOT TO RUN OL HOBARD CUST POINTED BITH HIS GUN AND SAID THAT BAY DOBN ON HIGHBAY
Score: 106
SELL GEORGIA SAM HE HAD A BLOODY NOSE SELAARE DEPARTMENT THEY SOULDNT GIBE HIM NO CLOTHES HE ASEED POOR HOSARD SHERE CAN I GO HOSARD SAID THERES ONLY ONE PLACE I ENOS SAM SAID TELL ME JUICE MAN I GOT TO RUN OL HOSARD CUST POINTED SITH HIS GUN AND SAID THAT SAY DOSN ON HIGHSAY
Score: 106
SELL GEORGIA SAM HE HAD A FLOODY NOSE SELAARE DEPARTMENT THEY SOULDNT GIBE HIM NO CLOTHES HE ASEED POOR HOSARD SHERE CAN I GO HOSARD SAID THERES ONLY ONE PLACE I ENOS SAM SAID TELL ME JUICE MAN I GOT TO RUN OL HOSARD CUST POINTED SITH HIS GUN AND SAID THAT SAY DOSN ON HIGHSAY
Score: 110
WELL GEORGIA SAM HE HAD A BLOODY NOSE WELFARE DEPARTMENT THEY WOULDNT GIVE HIM NO CLOTHES HE ASKED POOR HOWARD WHERE CAN I GO HOWARD SAID THERES ONLY ONE PLACE I KNOW SAM SAID TELL ME QUICK MAN I GOT TO RUN OL HOWARD BUST POINTED WITH HIS GUN AND SAID THAT WAY DOWN ON HIGHWAY
Score: 108
WELL GEORGIA SAM HE HAD A BLOODY NOSE WELFARE DEPARTMENT THEY WOULDNT GIBE HIM NO CLOTHES HE ASKED POOR HOWARD WHERE CAN I GO HOWARD SAID THERES ONLY ONE PLACE I KNOW SAM SAID TELL ME QUICK MAN I GOT TO RUN OL HOWARD BUST POINTED WITH HIS GUN AND SAID THAT WAY DOWN ON HIGHWAY
Score: 110
WELL GEORGIA SAM HE HAD A FLOODY NOSE WELFARE DEPARTMENT THEY WOULDNT GIVE HIM NO CLOTHES HE ASKED POOR HOWARD WHERE
CAN I GO HOWARD SAID THERES ONLY ONE PLACE I KNOW SAM SAID TELL ME QUICK MAN I GOT TO RUN OL HOWARD BUST POINTED WITH HIS GUN AND SAID THAT WAY DOWN ON HIGHWAY
Score: 108
WELL GEORGIA SAM HE HAD A FLOODY NOSE WELFARE DEPARTMENT THEY WOULDNT GIBE HIM NO CLOTHES HE ASKED POOR HOWARD WHERE CAN I GO HOWARD SAID THERES ONLY ONE PLACE I KNOW SAM SAID TELL ME QUICK MAN I GOT TO RUN OL HOWARD BUST POINTED WITH HIS GUN AND SAID THAT WAY DOWN ON HIGHWAY
....
....
....

References: http://april.eecs.umich.edu/pdfs/olson2007crypt.pdf http://www.blisstonia.com/shareware/WebDecrypto/howwork.php

About

Write a program to solve any letter substitution cipher automatically

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages