Accueil > > > CRYPTAGE DE MOTS/PHRASES.
CRYPTAGE DE MOTS/PHRASES.
Information sur la source
Description
Voici un programme qui crypte un mot ou une phrase à l'aide de l'algorythme de cryptage du chiffre de caesar.
Source
- # -*- coding: cp1252 -*-
- from Tkinter import *
-
-
- #--------------fonction qui crypte--------
- def crypt():
- mot = entree.get()
- cle = entree1.get()
- alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
- c = ""
- i,a = 0,0
- b,o = 0,0
- while len(c) < len(mot):
- if mot[i] in alph:
- if mot[i] == alph[a]:
- b = int(cle[o])
- c = c + alph[(a+b)%53]
- i += 1
- o = (o+1)%len(cle)
- a = (a+1)%53
- else:
- c = c + "*"
- i += 1
- crypter.set(c)
-
- #-------------fonction qui decrypt---------
- def decrypt():
- mot = entre.get()
- cle = entre1.get()
- alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
- c = ""
- i,a = 0,0
- b,o = 0,0
- while len(c) < len(mot):
- if mot[i] in alph:
- if mot[i] == alph[a]:
- b = int(cle[o])
- c = c + alph[(a-b)%53]
- i += 1
- o = (o+1)%len(cle)
- a = (a+1)%53
- else:
- c = c + "*"
- i += 1
- crypter1.set(c)
-
- #---- Prog Main ----
- fen = Tk()
- fen.title("By Bouceka")
-
- bou2 = Button(fen,text ='Quitter',fg ='red',command =fen.quit)
- bou2.grid(row =8,columnspan =2)
-
- #---- Cryptage -----
- Label(fen,text='.: CRYPTAGE :.',fg ='black').grid(row =0,columnspan =2)
- Label(fen,text='Texte a crypter : ',fg ='blue').grid(row =1,sticky =W)
- Label(fen,text='Clé de cryptage : ',fg ='blue').grid(row =2,sticky =W)
-
- crypter = StringVar()
- crypt1 = Entry(fen,textvariable = crypter)
- crypt1.grid(row =3,column =1)
- crypter.set("Texte crypté")
-
- entree = Entry(fen,fg='brown')
- entree.grid(row =1,column =1)
-
- mot = entree.get()
-
- entree1 = Entry(fen,fg ='brown')
- entree1.grid(row =2,column =1)
-
- bou1 = Button(fen,text ='Crypter',fg ='blue',command =crypt)
- bou1.grid(row = 3)
-
- #---- DECRYPTAGE ----
- Label(fen,text ='.: DECRYPTAGE :.',fg ='black').grid(row =4,columnspan =2)
-
- Label(fen,text ='Texte a décrypter : ',fg ='blue').grid(row =5,sticky =W)
- Label(fen,text ='Clé de décryptage : ',fg ='blue').grid(row =6,sticky =W)
-
- entre = Entry(fen,fg ='brown')
- entre.grid(row =5,column =1)
-
- entre1 = Entry(fen,fg ='brown')
- entre1.grid(row =6,column =1)
-
- crypter1 = StringVar()
- crypt2 = Entry(fen,textvariable = crypter1)
- crypt2.grid(row =7,column =1)
- crypter1.set("Texte décrypté")
-
-
-
- bou2 = Button(fen,text ='Décrypter',fg ='blue',command =decrypt)
- bou2.grid(row =7)
-
- fen.mainloop()
- fen.destroy()
-
# -*- coding: cp1252 -*-
from Tkinter import *
#--------------fonction qui crypte--------
def crypt():
mot = entree.get()
cle = entree1.get()
alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
c = ""
i,a = 0,0
b,o = 0,0
while len(c) < len(mot):
if mot[i] in alph:
if mot[i] == alph[a]:
b = int(cle[o])
c = c + alph[(a+b)%53]
i += 1
o = (o+1)%len(cle)
a = (a+1)%53
else:
c = c + "*"
i += 1
crypter.set(c)
#-------------fonction qui decrypt---------
def decrypt():
mot = entre.get()
cle = entre1.get()
alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
c = ""
i,a = 0,0
b,o = 0,0
while len(c) < len(mot):
if mot[i] in alph:
if mot[i] == alph[a]:
b = int(cle[o])
c = c + alph[(a-b)%53]
i += 1
o = (o+1)%len(cle)
a = (a+1)%53
else:
c = c + "*"
i += 1
crypter1.set(c)
#---- Prog Main ----
fen = Tk()
fen.title("By Bouceka")
bou2 = Button(fen,text ='Quitter',fg ='red',command =fen.quit)
bou2.grid(row =8,columnspan =2)
#---- Cryptage -----
Label(fen,text='.: CRYPTAGE :.',fg ='black').grid(row =0,columnspan =2)
Label(fen,text='Texte a crypter : ',fg ='blue').grid(row =1,sticky =W)
Label(fen,text='Clé de cryptage : ',fg ='blue').grid(row =2,sticky =W)
crypter = StringVar()
crypt1 = Entry(fen,textvariable = crypter)
crypt1.grid(row =3,column =1)
crypter.set("Texte crypté")
entree = Entry(fen,fg='brown')
entree.grid(row =1,column =1)
mot = entree.get()
entree1 = Entry(fen,fg ='brown')
entree1.grid(row =2,column =1)
bou1 = Button(fen,text ='Crypter',fg ='blue',command =crypt)
bou1.grid(row = 3)
#---- DECRYPTAGE ----
Label(fen,text ='.: DECRYPTAGE :.',fg ='black').grid(row =4,columnspan =2)
Label(fen,text ='Texte a décrypter : ',fg ='blue').grid(row =5,sticky =W)
Label(fen,text ='Clé de décryptage : ',fg ='blue').grid(row =6,sticky =W)
entre = Entry(fen,fg ='brown')
entre.grid(row =5,column =1)
entre1 = Entry(fen,fg ='brown')
entre1.grid(row =6,column =1)
crypter1 = StringVar()
crypt2 = Entry(fen,textvariable = crypter1)
crypt2.grid(row =7,column =1)
crypter1.set("Texte décrypté")
bou2 = Button(fen,text ='Décrypter',fg ='blue',command =decrypt)
bou2.grid(row =7)
fen.mainloop()
fen.destroy()
Historique
- 27 mai 2005 14:58:54 :
- Changement...
- 27 mai 2005 15:05:49 :
- changement...
- 26 juin 2005 15:08:24 :
- Ajout d'une interface graphique + un fichier ZIP.
- 15 octobre 2005 13:36:00 :
- Légère améiolaration du code.
- 15 octobre 2005 13:36:19 :
- Légère amélioration du code.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Cryptage DES [Python] [ par Kadaj676 ]
Bonjour j'aimerais savoir si vous aviez de la documentation sur des algo's de cryptage. Principalement DES, et je voudrais vosu demander, si il est po
Cryptage xor [ par sorcier0011 ]
Bonjour,J'aimerais bien faire un petit crypteur de texte xor mais je n'arrive pas a trouver comment convertir des lettres en Ascii. Parce que apart fa
Pour ne pas planter [ par franckysnow91 ]
Bonjour à tous,Je programme un algorithme sous python et malheureusement, je fais souvent des boucles perverses et je ne réussi pas à m'en sortir. Je
Algorithme Python parité [HELP] [ par Lyd3n ]
Bonjour, j'ai besoin d'aide pour un programme que je dois rendre a un professeur qui m'a poser des contraintes : je ne dois utiliser que "[i]input[/i
[Programme Python] Cryptage RSA (cherche codeur) [ par GelH ]
Bonjour, Je recherche un codeur Python capable de réaliser un programme de cryptage/décryptage d'une chaine de caractère utilisant l'algorithme RSA.
Morpion 3D [ par lola413 ]
Bonjour, Dans le cadre de mon cours de programmation j'ai pour exercice (a rendre pour le 23, youpi!) de réaliser un morpion 4*4 en 3D (alignement de
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
974 Application Server (12.2.4.0)974 APPLICATION SERVER (12.2.4.0)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP mySongBook Player (1.0.0)MYSONGBOOK PLAYER (1.0.0)mySongBook Player est un logiciel gratuit permettant l'accès à une archive de tablatures/partitio... Cliquez pour télécharger mySongBook Player
|