decoder_du_viginere.py

Created by jerem-jarsaillon

Created on March 02, 2024

748 Bytes


Carre=[]
ligne=[]
for j in range(26):
    for i in range(26):
        ligne.append(chr(65+(i+j)%26))
    Carre.append(ligne)
    ligne=[]
   
TexteClair=""
Cle=str(input("entrez la clef"))
lg_C=len(Cle)
bl=0
TexteCrypte=str(input("entrez le texte crypté"))
lg_tc=len(TexteCrypte)
for i in range(lg_tc):
    lettre=TexteCrypte[i]
    if lettre==" ":
        bl+=1
        TexteClair+=" "
    else:
        j=(i-bl)%lg_C
        j=ord(Cle[j])-65
        for l in range (26):
            if Carre[l][j]==lettre:
                TexteClair+= Carre[l][0]

print ("             Texte crypté :")
print (TexteCrypte)
print
print ("             Clé :")
print (Cle)
print
print ("             Texte clair :")
print (TexteClair)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.