[Tutor] Tutor Digest, Vol 94, Issue 58

Calle Calle_Python at live.se
Fri Dec 16 12:19:58 CET 2011


Message: 1
Date: Thu, 15 Dec 2011 23:37:49 +0100
From: "Calle" <Calle_Python at live.se>
To: "Robert Sjoblom" <robert.sjoblom at gmail.com>
Cc: tutor at python.org
Subject: Re: [Tutor] [TUTOR]Code Deciphering
Message-ID: <DUB109-DS7CD56B99F868568476224F8A30 at phx.gbl>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=original

-----Ursprungligt meddelande----- 
From: Robert Sjoblom
Sent: Thursday, December 15, 2011 10:34 PM
To: Calle
Cc: tutor at python.org
Subject: Re: [Tutor] [TUTOR]Code Deciphering

> I was wondering, how do you use Python to decipher codes? It feels like it
> should be pretty simple, but I haven't found any tutorials about it yet.

What kind of codes? Or do you mean ciphers? Generally speaking, a code
represent letters or numbers in transmitting a message. In other
words, a code deals with phrases and sentences or whole words. Example
"steal the cabbage at dawn" could mean "kill the king on wednesday".

A cipher deals with letters. It is a message written in letters in a
predetermined code. This means that a cipher is a system of
communication that uses letters instead of phrases. Examples being the
standard Caesar cipher where "APPLE" might be written "BQQMB" (ie,
shifted one letter to the right).
-- 
best regards,
Robert S.


--------------------------------------------------
Hi!

Sorry, I meant ciphers. How would a basic script for solving
move-one-step-to-the-right ciphers look like?

Have a nice day
//
Calle



------------------------------
------------------------------

Message: 3
Date: Fri, 16 Dec 2011 00:53:35 +0100
From: Robert Sjoblom <robert.sjoblom at gmail.com>
To: Calle <Calle_Python at live.se>
Cc: tutor at python.org
Subject: Re: [Tutor] [TUTOR]Code Deciphering
Message-ID:
<CAJKU7g3WEn1_sbhOfw49baYarz64kbYrDcATgct_xZPdN3gQyQ at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On 15 December 2011 23:37, Calle <Calle_Python at live.se> wrote:
> -----Ursprungligt meddelande----- From: Robert Sjoblom
> Sent: Thursday, December 15, 2011 10:34 PM
> To: Calle
> Cc: tutor at python.org
> Subject: Re: [Tutor] [TUTOR]Code Deciphering
>
>
>> I was wondering, how do you use Python to decipher codes? It feels like
>> it
>> should be pretty simple, but I haven't found any tutorials about it yet.
>
>
> What kind of codes? Or do you mean ciphers? Generally speaking, a code
> represent letters or numbers in transmitting a message. In other
> words, a code deals with phrases and sentences or whole words. Example
> "steal the cabbage at dawn" could mean "kill the king on wednesday".
>
> A cipher deals with letters. It is a message written in letters in a
> predetermined code. This means that a cipher is a system of
> communication that uses letters instead of phrases. Examples being the
> standard Caesar cipher where "APPLE" might be written "BQQMB" (ie,
> shifted one letter to the right).

> Sorry, I meant ciphers. How would a basic script for solving
> move-one-step-to-the-right ciphers look like?

Weeeell... There are different ways to solve that, but show us what
you've come up with so far and we might be able to point you in the
right direction. You won't learn anything by getting the answer posted
and just copy-paste it for whatever (nefarious) use you need it;
you'll learn a lot more if you work toward the solution yourself. I'll
just point you in the direction of ASCII values for now.

-- 
best regards,
Robert S.
------------------------------------

Well, I don't really know where to begin. I tried looking at other peoples
code and write something based on that, but it ended up being too similair
to the original code... I could show you what I came up with using
pseudo-code.

Get the cipher from user.
Use ord() to convert into numbers.
Add number to a new string while at the same time making it into a letter 
using chr().
Repeat 25 times and print the results.

Am I on the right track with this or should I re-think?

//
Calle 



More information about the Tutor mailing list