error in decoding shift cryptosystem
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))
Is it a homework?