how to decode a alphabet

Asked by asong defang

I have a program done already that has to encode and decode a string(ceaser cypher)
but they want us to decode the alphabetical letters to look like the alphabets below.i am confuse a bit.do i have to use if and for statements.i know i have to use chr to convert.please i need help

i have it on emacs but cannot copy to this word file.i have my string of the alphabetical letters but how to decode to be in the form
BJ YMJ UJTUQJ TK YMJ ZSNYJI XYFYJX, NS TWIJW YT KTWR F RTWJ UJWKJHY ZSNTS, JXYFGQNXM OZXYNHJ, NSXZWJ ITRJXYNH YWFSVZNQNYD, UWTANIJ KTW YMJ HTRRTS IJKJSXJ, UWTRTYJ YMJ LJSJWFQ BJQKFWJ, FSI XJHZWJ YMJ GQJXXNSLX TK QNGJWYD YT TZWXJQAJX FSI TZW UTXYJWNYD, IT TWIFNS FSI JXYFGQNXM YMNX HTSXYNYZYNTS KTW YMJ ZSNYJI XYFYJX TK FRJWNHF

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu emacs23 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
marcus aurelius (adbiz) said :
#1

according to wikipedia, a ceasar cypher is the simpliest of cyphers. it's just a shifting of letter an equal distance.

for example, if it's shifted by 1,

b = a
c = b
d = c

if it's shifted by 2,

c = a
d = b
e = c

etc.

is the text you're supposed to decyhper an actual sentence?

how you do it depends on which programming language you're using.

Revision history for this message
marcus aurelius (adbiz) said :
#2

according to the game show wheel of fortune, the letter R, S, T, N, L and E are the most commonly occuring letters in the English language. you can use this to try to figure out what the "shift" is. "the" is also the most comment word. so, look for a 3 character word and add the shift to see if it makes the word "the". if it does, then you've found out how many characters you need to shift to decode the cypher.

Revision history for this message
asong defang (asongamin) said :
#3

yes actually , i am decoding the letters of the alphabet and want to decode
I have already run the Ceasar cypher with a fixed rotation length on the preamble of the U. S. Constitution and captured the output into a file called code.txt. You can get a copy of it from my directory:

cp /afs/umbc.edu/users/b/o/bogar/pub/code.txt .
UNIX allows us to use the contents of a file as input to our program and also capture output from our program into a file. These operations are called redirection. The < is used when you're using a file for input and the > is used when you want to capture the output into a file. You can just think of these symbols as arrows to or from your programs name. Here are some examples of their use:

python lab3.py < preamble.txt
i have to write a program that tries to break the cipher, i dont know if i am doing it right.
#reads input string
input_string = input ("Enter input string: ")
#converts input string to all uppercase
uppercase_string = str.upper(input_string)
rotation_value = 1
for ch in uppercase_string:
    if ch != ' ':
        ascii_value = ord(ch)
        rotate_value = ((ascii_value - ord('A')) + rotation_value)%26 + ord('A')
        rotate_char = chr(rotate_value)
        print(rotate_char)

Revision history for this message
asong defang (asongamin) said :
#4

and also does this program calculate the correct shift amount by finding the letter used most often in the coded text and using the information in the letter frequencies chart shown below?

Revision history for this message
marcus aurelius (adbiz) said :
#5

by visual deduction, i was able to break the cypher in less than one minute. the second word YMJ = THE

you can use this as the basis to determine what the shift is that's needed to decrypt the message. depending on what your assignment is, this probably solves the problem for you. all that's left is to write a program that will translate the jumbled text into english.

how you code your program is up to you. imho, what you presented is very convoluted. there is a simpler way to program the decrypting program.

Can you help with this problem?

Provide an answer of your own, or ask asong defang for more information if necessary.

To post a message you must log in.