Bugku--凯撒部长的奖励

描述

在这里插入图片描述
凯撒密码,直接贴之前写的脚本:凯撒密码

脚本

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: moddemod
# datetime: 2019/12/26 下午3:27 
# ide: PyCharm

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 = "MSW{byly_Cm_sIol_lYqUlx_yhdIs_Cn_Wuymul_il_wuff_bcg_pCwnIl_cm_u_Yrwyffyhn_guh_cz_sio_quhn_ni_ayn_bcm_chzilguncihm_sio_wuh_dich_om}"
    encrypt(plaintext)

flag如下:
在这里插入图片描述

发布了147 篇原创文章 · 获赞 4 · 访问量 6835

猜你喜欢

转载自blog.csdn.net/weixin_43833642/article/details/103716424
今日推荐