MIT-Curricular/IS/Lab/Lab1/q5_john.py
2025-08-05 07:23:18 +05:30

21 lines
501 B
Python

def main():
shift = (ord('C') - ord('y')) % 26
ctext = "XVIEWYWI"
plaintext = ""
for char in ctext:
if char.isalpha():
shifted = ord(char.lower()) - shift
if shifted < ord('a'):
shifted += 26
plaintext += chr(shifted)
else:
plaintext += char
print(f"Attack type: Known plaintext attack")
print(f"Ciphertext: {ctext}")
print(f"Decrypted: {plaintext}")
if __name__ == '__main__':
main()