I want to know hoe can solve this error

asked 2022-04-04 20:30:56 +0200

SKUN gravatar image

updated 2022-04-05 19:28:47 +0200

Max Alekseyev gravatar image

I want to shift backward to decrypt, but when I write k=-7, it it error that k is outside of range, so how can I correct it?

shift_system = ShiftCryptosystem(AlphabeticStrings())
message = "The shift cryptosystem generalizes the Caeser cipher"
plaintext = shift_system.encoding(message)
print("plaintext:", plaintext)
key = 7
encode = shift_system(key)
ciphertext = encode(plaintext)
print("ciphertext:", ciphertext)
decode = shift_system(shift_system.inverse_key(key))
print("Decoding ciphertext gives plaintext?", plaintext == decode(ciphertext))
edit retag flag offensive close merge delete

Comments

Is it a homework?

Max Alekseyev gravatar imageMax Alekseyev ( 2022-04-05 23:26:54 +0200 )edit