Programme masque jetable (python)
Bonjour, actuellement en terminale s pour mon projet d isn je suis confronté à un problème avec mon programme de masque jetable , au niveau de la fonction codage je ne sais pas comment transformer mon nombre binaire en caractère, voila le code :
def transformationenbinaire (mot):
chaine=""
for k in range(len(mot)):
codek=ord(mot[k]) #code ascii de la lettre
a=bin (codek) [2:].zfill(8)
print k," ",
chaine+=a
return chaine
def transformationenbinaire2 (mot):
chaine=""
for lettre in mot:
chaine+=bin (ord(lettre)) [2:].zfill(8)
return chaine
def xor (motbin,clebin):
return str(int(((motbin and not clebin)or(clebin and not motbin))))
def xormot(mot1,mot2):
chaine=""
for k in range (len(mot1)):
chaine+=xor(int(mot1[k]),int(mot2[k]))
return chaine
def codage(motcodebin):
mot=raw_input("Entrer votre message:")
cle=raw_input("Entrer la cle:")
motbin= transformationenbinaire2(mot)
clebin= transformationenbinaire2(cle)
motcodebin=xormot(motbin,clebin)
motcode=codage(motcodebin)
print motcode
Merci d'avance