def encrypt_text(cleartext: str = 'Bitcoin', incrementation: int = 13): encrypted_text = '' for char in cleartext: encrypted_text += increment_char(char, incrementation) return encrypted_text def increment_char(char, incrementation: int = 1): # converting character to byte char_in_bytes = bytes(char, 'utf-8')[0] if char_in_bytes + incrementation >= 91 and char_in_bytes < 91 \ or char_in_bytes + incrementation >= 123: # z -> 122 | 90 -> Z so go backwards new_char_in_bytes = bytes([char_in_bytes - (26 - incrementation)]) else: new_char_in_bytes = bytes([char_in_bytes + incrementation]) return str(new_char_in_bytes)[2] def decrypt_text(encrypted_text: str = 'Ovgpbva', incrementation: int = 13): cleartext = '' for char in encrypted_text: cleartext += increment_char(char, 26 - incrementation) return cleartext if __name__ == '__main__': print(encrypt_text()) print(decrypt_text())