Can I get some pointers on writing a program to decipher cryptograms? I'm not sure where to start. This is an example:
bthhy gwtqt! wyo pl cyxq zkv eypre?
7 4775
Can I get some pointers on writing a program to decipher cryptograms? I'm not sure where to start. This is an example:
bthhy gwtqt! wyo pl cyxq zkv eypre?
I think you should start off with a huge word list in a file so python can know what to look for but i'm not sure. Just an idea.
Wait do you mean like a word scrambler/unscrambler or a kind of like a decoder that tries to decode the message??
A decoder. I have written a word unscrambler but I like to do cryptograms from a crossword puzzle book and thought it would be fun to try to write a program that could decipher them.
A decoder. I have written a word unscrambler but I like to do cryptograms from a crossword puzzle book and thought it would be fun to try to write a program that could decipher them.
After unscrambling a word you could do something like: -
import win32com.client
-
-
msword = win32com.client.Dispatch("Word.Application")
-
-
string = "Here is some texxt with a coupple of problems"
-
-
for word in string.split():
-
if msword.CheckSpelling(word):
-
print "!%s! OK!" % word
-
else:
-
print "?%s? ->"%word,
-
suggestions = msword.GetSpellingSuggestions(word)
-
for suggest in suggestions:
-
print suggest.Name,
-
print
-
on Windows or check with ispell using popen() on *nix.
Ya, I don't need to unscramble the words first but I have written a simple word unscrambler before. I was wondering where to start to write a program to solve a cryptogram without a key. So if:
a = "h"
b = "i"
c = "j"
d = "x"
e = "t"
f = "r"
g = "e"
and the puzzle was: ab eagrg!
the solution would be: hi there!
BUT.....how can it be done without having a key to the solution? Cryptograms are fun and I can usually solve them with paper and pencil but I figured I'd give myself a challenge and see if I could come up with a program that could do it.
Ya, I don't need to unscramble the words first but I have written a simple word unscrambler before. I was wondering where to start to write a program to solve a cryptogram without a key. So if:
a = "h"
b = "i"
c = "j"
d = "x"
e = "t"
f = "r"
g = "e"
and the puzzle was: ab eagrg!
the solution would be: hi there!
BUT.....how can it be done without having a key to the solution? Cryptograms are fun and I can usually solve them with paper and pencil but I figured I'd give myself a challenge and see if I could come up with a program that could do it.
That's a good one. For a given problem that you know how to solve with paper and pencil, start by writing down the steps you take with the given info, what new info you have after step 1, and so on, until the entire algorithm unfolds. Once you have a possible algorithm, then it's time to ask "how can I make the computer perform this algorithm?".
I found the following at:
http://mail.python.org/pipermail/python-list/2002-September/165558.html -
"""
-
Ha'f ahoy ad ayfa wdqr srxhekdpyr! H phmm zhby
-
fhv odeajf dc cryy pys jdfahez ad ajy chrfa kyrfde
-
ad fdmby ajhf irwkadzrxo. Ixe wdq chzqry ha dqa?
-
-
Fheiy wdq jxby axgye ow ijxmmyezy xet tyirwkayt
-
ajy fyirya oyffxzy, H phmm ybye zhby wdq ajy
-
irwkadzrxo-oxghez fdqriy idty ad xoxuy wdqr
-
crhyetf!
-
"""
-
hokdra fwf, farhez, rxetdo
-
ihkjyr = mhfa(farhez.myaayrf[:26])
-
rxetdo.fjqccmy(ihkjyr)
-
ihkjyr = "".ldhe(ihkjyr)
-
ihkjyr += ihkjyr.qkkyr()
-
oxk = {}
-
cdr kmxhe, irwka he uhk(farhez.myaayrf, ihkjyr):
-
oxk[kmxhe] = irwka
-
cdr mhey he dkye(fwf.xrzb[1]):
-
krhea "".ldhe([oxk.zya(ij,ij) cdr ij he mhey])[:-1]
-
-
Now if I was to start thinking this one out, I'd start with single letters which are usually either 'A' or 'I' and also take a look at any words with an appostrophe, then I'd look for possible 'and' or 'the' type structures, double letters,and any questions, which usually start with: is, am, are, who, what, where, when, how, why, can, can't, do, don't, may, will, won't, etc. but again the appostrophe comes in to play as well as the amount of letters in the word.
I have the solution to this one but wouldn't find it hard to start myself. Here's someones solution to it: -
def decrypt(yourstring):
-
dedict = {'F': 'S', 'I': 'C', 'H': 'I', 'a': 't', 'c': 'f', 'b': 'v', 'e': 'n',
-
'd': 'o', 'f': 's', 'i': 'c', 'h': 'i', 'k': 'p', 'j': 'h', 'm': 'l',
-
'l': 'j', 'o': 'm', 'q': 'u', 'p': 'w', 's': 'b', 'u': 'z', 't': 'd',
-
'w': 'y', 'v': 'x', 'y': 'e', 'x': 'a', 'z': 'g', 'g': 'k'}
-
return "".join([dedict.get(i,i) for i in yourstring])
-
-
returns
-
-
"""
-
It's time to test your brainpower! I will give
-
six months of free web hosting to the first person
-
to solve this cryptogram. Can you figure it out?
-
-
Since you have taken my challenge and decrypted
-
the secret message, I will even give you the
-
cryptogram-making source code to amaze your
-
friends!
-
"""
-
import sys, string, random
-
cipher = list(string.letters[:26])
-
random.shuffle(cipher)
-
cipher = "".join(cipher)
-
cipher += cipher.upper()
-
map = {}
-
for plain, crypt in zip(string.letters, cipher):
-
map[plain] = crypt
-
for line in open(sys.argv[1]):
-
print "".join([map.get(ch,ch) for ch in line])[:-1]
-
This was posted in 2002 but I didn't know if some of this code could be used without the given key.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nat |
last post by:
Hi there,
I have code as following but it returns error
Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
/urbisjhdintranet/metadata/resultList.asp, line 324
which is the...
|
by: GAVO. |
last post by:
This probably is not the best group to post this question but any ways.
I've been working with ms access for the last couple of years and gotten
very good at it. I have never been on any ms...
|
by: Mr. Mountain |
last post by:
In the following code I simulate work being done on different threads by
sleeping a couple methods for about 40 ms. However, some of these methods
that should finish in about 40 -80 ms take as long...
|
by: John Salerno |
last post by:
Just a quickie for today: Is it common (and also preferred, which are
two different things!) to create a function that has the sole job of
calling another function?
Example: for fun and...
|
by: Odinn |
last post by:
Greetings , This is my first year at programming and 3rd week at this
so count me as a pure newbie.
I am trying to make a program that gets a number and prints out starts
as this:
For input 3 :...
|
by: saundra |
last post by:
This appears to be the code that is giving me trouble. Can someone help
<?
include("common.php");
require_once("$HeaderFile");
if(empty($_GET)){
$Start = '0';
}else{
$Start = $_GET;
|
by: =?Utf-8?B?cm9jY28=?= |
last post by:
Hello,
easy question:
- what are the best books to start learning C#?
Thanks!
Rocco
|
by: Ceebaby via AccessMonster.com |
last post by:
Hi Folks
I wondered if someone could point me in the right direction before I
completely tear my hair out.
I have a user selection form where options can be selected for a report.
Users now...
|
by: Phlip |
last post by:
1230987za wrote:
Kanze is a classically-trained "unit tester". In some circles "unit" is a QA
concept - specifically, if a test fails, you only need to inspect one unit.
So "units" are...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |