20 lines
496 B
Python
20 lines
496 B
Python
def main():
|
|
shift = (ord('C') - ord('y')) % 26
|
|
|
|
ctext = "XVIEWYWI"
|
|
plaintext = []
|
|
|
|
for ch in ctext:
|
|
if ch.isalpha():
|
|
base = ord('a')
|
|
shifted = (ord(ch.lower()) - base - shift) % 26 + base
|
|
plaintext.append(chr(shifted))
|
|
else:
|
|
plaintext.append(ch)
|
|
|
|
print(f"Attack type: Known plaintext attack")
|
|
print(f"Ciphertext: {ctext}")
|
|
print(f"Decrypted: {''.join(plaintext)}")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|