用户:Ryan袁奥查看:0 回复:4 评论:0 创建时间:2018-12-04T19:25:41
下面,我展一个python代码,大家可以自行研究!
【案例一】:明文加密
import easygui
plain_text = easygui.enterbox("请输入要加密的明文:")
n = int(easygui.enterbox("请输入加密的偏移量:")) % 26
easygui.msgbox("加密中.")
easygui.msgbox("加密中..")
easygui.msgbox("加密中...")
cipher_text = ''
temp = 0
for i in range(len(plain_text)):
if n + ord(plain_text[i]) <= 122:
temp = chr(n + ord(plain_text[i]))
cipher_text = cipher_text + temp
else:
temp = chr((n + ord(plain_text[i])) - 26)
cipher_text = cipher_text + temp
easygui.msgbox("加密完毕!")
easygui.msgbox("加密后的密文是:%s"%(cipher_text))
大家可以运行这段代码试试看,是不是很有趣呢?
活动喵恭喜Ryan袁奥工作室发布编程一小时帖子/作品一篇,工作室积分+2,积分累计截止到12月12日,活动详情请查看链接:https://www.codemao.cn/community/167979
再接再厉,活动喵相信你们工作室能成功拿下前六,获得工作室专属荣誉及奖品!

点赞0
评论