Ejemplo 1: cifrado python ascii caesar
def ascii_caesar_shift(message, distance):
encrypted = ""
for char in message:
value = ord(char) + distance
encrypted += chr(value % 128) #128 for ASCII
return encrypted
Ejemplo 2: cifrado césar de python
def caesar_encrypt():
word = input('Enter the plain text: ')
c = ''
for i in word:
if (i == ' '):
c += ' '
else:
c += (chr(ord(i) + 3))
return c
def caesar_decrypt():
word = input('Enter the cipher text: ')
c = ''
for i in word:
if (i == ' '):
c += ' '
else:
c += (chr(ord(i) - 3))
return c
plain = 'hello'
cipher = caesar_encrypt(plain)
decipher = caesar_decrypt(cipher)
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)