Apuntes
CaesarCmk4
Contenido del apunte (1)
Página 1
Version:1.0
StartHTML:0000000166
EndHTML:0000007605
StartFragment:0000001987
EndFragment:0000007569
SourceURL:file:///Users/aleccheung/Documents/Caesar%20C.doc
#Fully functional Caesar Cipher decryption
program
program='y'
while program.lower()=='y':
Normal=input ('Please enter the sentence you
wish to encrypt (numbers and symbols will not be encrypted): ')
Key=input('Please enter the key (1-26) ')
total=""
if (int(Key))
for char in Normal:
if char.isupper():
EncryptedU=ord(char)-int(Key)
if EncryptedU
EncryptedU=EncryptedU+26
total=total+chr(int(EncryptedU))
else:
total=total+chr(int(EncryptedU))
elif char.islower():
EncryptedL=ord(char)-int(Key)
if
EncryptedL
EncryptedL=EncryptedL+26
total=total+chr(int(EncryptedL))
else:
total=total+chr(int(EncryptedL))
else:
total=total+(char)
print('Your Encrypted
message is: '+total)
program=input('Encrypt
another program [y/n]?')
Información
- Descripción
- Apunte sobre CaesarCmk4, creado por acheung el 19/03/2015.
- Creado por
- acheung
- Visitas
- 5
- Valoración