-
最近做了点misc的题,解题用的脚本
-
从1到25遍历各种移位,密文直接改ciphertext变量值即可
def caesar_decrypt(ciphertext, shift):
plaintext = ""
for char in ciphertext:
if char.isalpha():
ascii_offset = ord('a') if char.islower() else ord('A')
decrypted_char = chr((ord(char) - ascii_offset - shift) % 26 + ascii_offset)
plaintext += decrypted_char
else:
plaintext += char
return plaintext
ciphertext = "mshn{P aopur Paz aol ilza huzdly}"
for shift in range(26):
decrypted_text = caesar_decrypt(ciphertext, shift)
print(f"Shift {shift}: {decrypted_text}")