| | |
ceaser cypher
This code takes a string a cyphers it by shifting it's position in the alphabet. I've gotten it so it can pretty much take paragraphs. It's quite neat to play with.
For example the above when shifted to 5, would be:
Ymnx htij yfpjx f xywnsl f hDumjwx ny gD xmnkynsl ny,x utxnynts ns ymj fqumfgjy= N,Aj ltyyjs ny xt ny hfs uwjyyD rzhm yfpj ufwflwfumx= Ny,x vznyj sjfy yt uqfD Bnym=
For example the above when shifted to 5, would be:
Ymnx htij yfpjx f xywnsl f hDumjwx ny gD xmnkynsl ny,x utxnynts ns ymj fqumfgjy= N,Aj ltyyjs ny xt ny hfs uwjyyD rzhm yfpj ufwflwfumx= Ny,x vznyj sjfy yt uqfD Bnym=
import string numbers = "" x = 0 while x < 11: numbers = numbers + str(x) x += 1 shift = int(raw_input("Pick shift key from 1-9")) choice = raw_input("would you like to encode or decode?") letters = string.ascii_letters + string.punctuation + numbers word = (raw_input("Please enter text")) print letters encoded = '' if choice == "encode": for letter in word: if letter == ' ': encoded = encoded + ' ' else: x = letters.index(letter) + shift encoded = encoded + letters[x] if choice == "decode": for letter in word: if letter == ' ': encoded = encoded + ' ' else: x = letters.index(letter) - shift encoded = encoded + letters[x] print encoded
0
•
•
•
•
Removed [ code][ inlinecode] ... [ /inlinecode][ /code] tags.
Note, you could use
letters = string.ascii_letters + string.punctuation + string.digits
Note, you could use
letters = string.ascii_letters + string.punctuation + string.digits
0
•
•
•
•
A caeser cypher with a shift of 13 is known as ROT13 just incase you didn't know that and it's the easiest cypher I know of to code besides an XOR
0
•
•
•
•
This coding looks very similar to shell scripting for Unix. Interesting.
http://www.1-satellite-tv-facts.com
http://www.1-satellite-tv-facts.com/Direct-TV.html
http://www.1-satellite-tv-facts.com/Dish-Network.html
http://www.1-satellite-tv-facts.com/...ite-Radio.html
http://www.1-satellite-tv-facts.com/...t-Service.html
http://www.1-satellite-tv-facts.com/Satellite-DSL.html
http://www.1-satellite-tv-facts.com/...-Internet.html
http://www.1-satellite-tv-facts.com/VoIP.html
http://www.1-satellite-tv-facts.com/Phone-Systems.html
http://www.1-satellite-tv-facts.com/...-Programs.html
http://www.1-satellite-tv-facts.com
http://www.1-satellite-tv-facts.com/Direct-TV.html
http://www.1-satellite-tv-facts.com/Dish-Network.html
http://www.1-satellite-tv-facts.com/...ite-Radio.html
http://www.1-satellite-tv-facts.com/...t-Service.html
http://www.1-satellite-tv-facts.com/Satellite-DSL.html
http://www.1-satellite-tv-facts.com/...-Internet.html
http://www.1-satellite-tv-facts.com/VoIP.html
http://www.1-satellite-tv-facts.com/Phone-Systems.html
http://www.1-satellite-tv-facts.com/...-Programs.html
Similar Threads
- Creating a replacement cypher with triple-quoted strings (Python)
- Python-Cypher Generator (Python)
- Cypher Question (Python)
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment backend beginner binary bluetooth builtin calculator character cmd converter countpasswordentry curved customdialog dan08 data decimals dictionary directory dynamic exe file float format function gnu graphics heads homework http ideas inches input java leftmouse library line lines linux list lists loop module mouse mysqlquery number numbers numeric output parsing path phonebook plugin pointer prime programming progressbar push py2exe pygame python random recursion redirect schedule screensaverloopinactive script scrolledtext software sqlite statictext statistics string strings sudokusolver table terminal text thread time tlapse trick tuple twoup ubuntu unicode urllib urllib2 variable ventrilo wikipedia wordgame write wxpython xlib



