[HBNIS2018]caesar

[HBNIS2018]caesar

image-20220730232701203

直接凯撒密码脚本爆破这段字符gmbhjtdbftbs

def encrypt(plaintext):
	# j即为key
    for j in range(26):
        str_list = list(plaintext)
        i = 0
        while i <len(plaintext):
            if not str_list[i].isalpha():
                str_list[i] = str_list[i]
            else:
                a = "A" if str_list[i].isupper() else "a"
                str_list[i] = chr((ord(str_list[i]) - ord(a) + j) % 26 + ord(a))
            i = i + 1

        print(''.join(str_list))

if __name__ == '__main__':
    plaintext = "gmbhjtdbftbs"
    encrypt(plaintext)

image-20220730232749008

flag{flagiscaesar}

posted @ 2022-07-30 23:29  Jinx8823  阅读(184)  评论(0编辑  收藏  举报