cryptage_cesar.py

Created by elodie-gamot

Created on November 03, 2021

604 Bytes

Crypter un texte avec le code de César (décalage de trois lettres)


alphabet = "abcdefghijklmnopqrstuvwxyz"

def conversion(k):
  return alphabet.find(k)
#Fonction str.find() renvoie la position du caratère k

def crypt(k):
  position = (conversion(k)+3)%26
  return alphabet[position]  
#La position du caractère k est modifié de trois rangs
#La fonction renvoie le caractère de l'alphabet correspondant
#à la nouvelle position.

def text():
  cryp=""
  mot=input('Mot à crypter:')
  for letter in mot:
    cryp += crypt(letter)
  return(cryp)
#Création d'une chaîne de caractères après application
#successive de la fonction précédente.

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.