Sinisterly
Crypter: Cesar Cipher - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: Crypter: Cesar Cipher (/Thread-Crypter-Cesar-Cipher)



Crypter: Cesar Cipher - hunt3r972 - 12-26-2013

This is a python script I made, allowing you to crypt/decrypt a message using the cesar code methode.

Code:
#!/usr/bin/env python3.3 #RUN WITH python codecesar.py #YOU CAN USE SPECIAL CHARS import sys choixmenu=raw_input("Do you want to crypt or decrypt ? type 1 to crypt or 2 to decrypt: ") while (choixmenu != "1") and (choixmenu != "2"): #On verifie que 1 ou 2 est demande sinon on demande a nouveau choixmenu=raw_input("You must type 1 or 2 ? type 1 to crypt or 2 to decrypt: ") if choixmenu == "1": #On veut encoder #On initialise le dictionnaire pour la cle dicle = {'A':0, 'a':0, 'B':1, 'b':1, 'C':2, 'c':2, 'D':3, 'd':3, 'E':4, 'e':4, 'F':5, 'f':5, 'G':6, 'g':6, 'H':7, 'h':7, 'I':8, 'i':8, 'J':9, 'j':9, 'K':10, 'k':10, 'L':11, 'l':11, 'M':12, 'm':12, 'N':13, 'n':13, 'O':14, 'o':14, 'P':15, 'p':15, 'Q':16, 'q':16, 'R':17, 'r':17, 'S':18, 's':18, 'T':19, 't':19, 'U':20, 'u':20, 'V':21, 'v':21, 'W':22, 'w':22, 'X':23, 'x':23, 'Y':24, 'y':24, 'Z':25, 'z':25} choixcle=raw_input("Type the letter you want to use to crypt your message: ") cle=dicle[choixcle]; #On recupere la valeur correspondante a la lettre choisie dans le dictionnaire message=raw_input("Type your message: ") message=message.upper() #On passe le message en majuscule for i in message: valascii=ord(i) #On recupere la valeur ascii de chaque lettre if (valascii >= 65) and (valascii <= 90): #On initialiste le dictionnaire qui fait la correspondance valeure ascii->chiffre normal dichiffre = {65:0, 66:1, 67:2, 68:3, 69:4, 70:5, 71:6, 72:7, 73:8, 74:9, 75:10, 76:11, 77:12, 78:13, 79:14, 80:15, 81:16, 82:17, 83:18, 84:19, 85:20, 86:21, 87:22, 88:23, 89:24, 90:25} valnormal=dichiffre[valascii]; convertion=(valnormal+cle)%26 #On initialiste le dictionnaire qui fait la correspondance valeure chiffre normal->ascii dicascii = {0:65, 1:66, 2:67, 3:68, 4:69, 5:70, 6:71, 7:72, 8:73, 9:74, 10:75, 11:76, 12:77, 13:78, 14:79, 15:80, 16:81, 17:82, 18:83, 19:84, 20:85, 21:86, 22:87, 23:88, 24:89, 25:90} valascii2=dicascii[convertion]; else: dicspecar = {32:32, 33:33, 34:34, 35:35, 36:36, 37:37, 38:38, 39:39, 40:40, 41:41, 42:42, 43:43, 44:44, 45:45, 46:46, 47:47, 48:48, 49:49, 50:50, 51:51, 52:52, 53:53, 54:54, 55:55, 56:56, 57:57, 58:58, 59:59, 60:60, 61:61, 62:62, 63:63, 64:64, 91:91, 92:92, 93:93, 94:94, 95:95, 96:96, 123:123, 124:124, 125:125, 126:126} valascii2=dicspecar[valascii] resultat=chr(valascii2) #On transforme le code ascii en caractere lisible sys.stdout.softspace=0 print resultat, elif choixmenu == "2": #On veut decoder #On initialise le dictionnaire pour la cle dicle = {'A':0, 'a':0, 'B':1, 'b':1, 'C':2, 'c':2, 'D':3, 'd':3, 'E':4, 'e':4, 'F':5, 'f':5, 'G':6, 'g':6, 'H':7, 'h':7, 'I':8, 'i':8, 'J':9, 'j':9, 'K':10, 'k':10, 'L':11, 'l':11, 'M':12, 'm':12, 'N':13, 'n':13, 'O':14, 'o':14, 'P':15, 'p':15, 'Q':16, 'q':16, 'R':17, 'r':17, 'S':18, 's':18, 'T':19, 't':19, 'U':20, 'u':20, 'V':21, 'v':21, 'W':22, 'w':22, 'X':23, 'x':23, 'Y':24, 'y':24, 'Z':25, 'z':25} choixcle=raw_input("Type the letter you want to use to decrypt your message: ") cle=dicle[choixcle]; #On recupere la valeur correspondante a la lettre choisie dans le dictionnaire message=raw_input("Type your message: ") message=message.upper() #On passe le message en majuscule for i in message: valascii=ord(i) #On recupere la valeur ascii de chaque lettre if (valascii >= 65) and (valascii <= 90): #On initialiste le dictionnaire qui fait la correspondance valeure ascii->chiffre normal dichiffre = {65:0, 66:1, 67:2, 68:3, 69:4, 70:5, 71:6, 72:7, 73:8, 74:9, 75:10, 76:11, 77:12, 78:13, 79:14, 80:15, 81:16, 82:17, 83:18, 84:19, 85:20, 86:21, 87:22, 88:23, 89:24, 90:25} valnormal=dichiffre[valascii]; convertion=(valnormal-cle)%26 #On initialiste le dictionnaire qui fait la correspondance valeure chiffre normal->ascii dicascii = {0:65, 1:66, 2:67, 3:68, 4:69, 5:70, 6:71, 7:72, 8:73, 9:74, 10:75, 11:76, 12:77, 13:78, 14:79, 15:80, 16:81, 17:82, 18:83, 19:84, 20:85, 21:86, 22:87, 23:88, 24:89, 25:90} valascii2=dicascii[convertion]; else: dicspecar = {32:32, 33:33, 34:34, 35:35, 36:36, 37:37, 38:38, 39:39, 40:40, 41:41, 42:42, 43:43, 44:44, 45:45, 46:46, 47:47, 48:48, 49:49, 50:50, 51:51, 52:52, 53:53, 54:54, 55:55, 56:56, 57:57, 58:58, 59:59, 60:60, 61:61, 62:62, 63:63, 64:64, 91:91, 92:92, 93:93, 94:94, 95:95, 96:96, 123:123, 124:124, 125:125, 126:126} valascii2=dicspecar[valascii] resultat=chr(valascii2) #On transforme le code ascii en caractere lisible resultat=resultat.lower() sys.stdout.softspace=0 print resultat,

I coded it in french but I'll translate it. Anyway it's simple:

Choose 1 to crypt and 2 to decrypt
Choose the letter used for coding
Type your message

Same thing to decrypt


RE: Crypter: Cesar Code - Yves Josue - 12-26-2013

great i go to try this (y)


RE: Crypter: Cesar Code - Slarek - 12-26-2013

Check this: http://www.hackcommunity.com/Thread-caesar-cipher


RE: Crypter: Cesar Code - hunt3r972 - 12-26-2013

(12-26-2013, 03:36 PM)Slarek Wrote: Check this: http://www.hackcommunity.com/Thread-caesar-cipher
Didn't see that. Can I post mine ? I also have the frequency analyzer that allow you to find the key


RE: Crypter: Cesar Code - oPxH4ck3r - 12-26-2013

good works thanks man


RE: Crypter: Cesar Code - Slarek - 12-26-2013

Yes you can. It's not closed yet.