Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

16 Commits

Repository files navigation

CaeserCipher in Python

I have used strings rather than converting strings to ASCII I felt it easier

defencrypt(message, shift_number):
''' parameter: message, shift_number returns : encrypted_result just encrypts the message '''total_possibilities='abcdefghijklmnopqrstuvwxyz'encrypted_result=''forcharacterinmessage:
index=total_possibilities.find(character.lower())
ifindex==-1:
encrypted_result+=characterelse:
output_index= (index+shift_number) %len(total_possibilities)
encrypted_result+=total_possibilities[output_index]
returnencrypted_result.upper()
defdecrypt(message, shift_number):
''' parameter: message, shift_number returns: decrypted_result just decrupts the message '''total_possibilities='abcdefghijklmnopqrstuvwxyz'decrypted_result=''forcharacterinmessage:
index=total_possibilities.find(character.lower())
ifindex==-1:
decrypted_result+=characterelse:
output_index= (index-shift_number) %len(total_possibilities)
decrypted_result+=total_possibilities[output_index]
returndecrypted_result.upper()

About

caeser cipher in python

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages