python ascii caesar cipher
def ascii_caesar_shift(message, distance):
encrypted = ""
for char in message:
value = ord(char) + distance
encrypted += chr(value % 128) #128 for ASCII
return encrypted
python ascii caesar cipher
def ascii_caesar_shift(message, distance):
encrypted = ""
for char in message:
value = ord(char) + distance
encrypted += chr(value % 128) #128 for ASCII
return encrypted
caesar cipher python
def cc_encrypt(msg: str,key: int) -> str:
encrypted_msg = ''
try:
for char in msg:
encrypted_msg += str(chr(ord(char)+int(key)))
except:
print(Exception)
pass
return encrypted_msg
def cc_decrypt(msg: str,key: int) -> str:
decrypted_msg = ''
try:
for char in msg:
decrypted_msg += chr(ord(char)-int(key))
except:
print(Exception)
pass
return decrypted_msg
message = 'Hello World!'
key = 9
print(f'Caesar Cipher:nEncrypted: {cc_encrypt(message,key)}nDecrypted: {cc_decrypt(cc_encrypt(message,key),key)}')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us