贴一个统计密文字符的脚本

发布于 2023-05-30  309 次阅读


  • 最近做了点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}")
届ける言葉を今は育ててる
最后更新于 2024-02-07