猫史档案馆


【编程一小时】python案例代码展示·第一期

用户:Ryan袁奥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))

大家可以运行这段代码试试看,是不是很有趣呢?


回复

上一页1 页 / 共 1下一页
Ryan袁奥Ryan袁奥

本帖解释权为Ryan袁奥工作室所有,请活动喵积分+1!

点赞0


评论


活动喵活动喵

恭喜Ryan袁奥工作室发布编程一小时帖子/作品一篇,工作室积分+2,积分累计截止到12月12日,活动详情请查看链接:https://www.codemao.cn/community/167979
再接再厉,活动喵相信你们工作室能成功拿下前六,获得工作室专属荣誉及奖品!

emotion_编程猫_加油

点赞0


评论


一块软糖一块软糖

最晚哈哈

 

点赞0


评论


kkk_AC工作室toby小号kkk_AC工作室toby小号

现在我都有密匙加密...长度完全不同

点赞0


评论