MIT-Curricular/IS/Lab/Lab1/q5_john.py
2025-08-12 09:43:39 +05:30

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()