123456789101112131415161718192021 |
- def cesar_cipher(text, key=3):
- result = ""
- i = 0
- while i < len(text):
- char = text[i]
- if char.isupper():
- result += chr((ord(char) - 65 + key) % 26 + 65)
- else:
- result += chr((ord(char) - 97 + key) % 26 + 97)
- i += 1
- return result
- # Chiamata della funzione utilizzando keyword arguments
- text = "Inserisci il testo da cifrare"
- key = 3
- print("Testo cifrato: ", cesar_cipher(text=text))
|