设计工作1:升级的凯撒加密算法的仿真软件实现
1.凯撒升级版设计解密软件界面如图所示:
2.操作如下:单击“加载密文文件”按钮,加载cipher.txt。
然后点击“解密”按钮,看看明文是对是错
如果您觉得翻译后的明文不正确,则意味着字母映射表中的第二行设置不正确。请修改第二行字母映射表,然后单击再次使用“解密”按钮,直到解密的明文正确。
最后,当你确保第二行被猜测正确时,你将得到关键的句子。最后,解释一下关键的句子是什么,并对你的每个句子进行字面理论分析step(给出密钥句子,并且对你的每一步做理论上的分析).
“清除密文”按钮的功能是清除密文文本框。
3.凯撒密码升级版的原理如下:
其中的一个例子如下所示。
the plain text(明文): I am in danger!
The key sentence(密钥句子): zhangsan.
小写明文字母与大写明文字母之间的映射关系如表1所示,构造方法如下:明文字母的第一行为fi有26封字母
第二行密文字母顺序构造规则:首先删除关键字(张山)中的重复字母,然后写入密文字母的第二行等等,然后写入26个没有按照字母表顺序使用的字母中的剩余字母。
表1映射表(明文为小写,密文为大写)
Plaintext a b c d e f g h i j k l m n o p q r s t u v w x y z
Ciphertext Z H A N G S B C D E F I J K L M O P Q R T U V W X Y
|—关键词——|——其余26个字母按字母顺序写成,–|
(plaintext is uppercase, the ciphertext is lowercase)
Plaintext A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Ciphertext z h a n g s b c d e f i j k l m o p q r t u v w x y
|— Key sentence —|---The remaining letters of 26 lettersare written in alphabetical order --|
|—关键词——|——其余26个字母按字母顺序写成,–|
With the mapping table, then the text is I am in danger! The ciphertext is d ZJ DK NZKBGP!
.注:生成函数中的映射表是所有字母的对应映射表,包括大写字母的映射表和小写字母的映射表。
下面是代码:
import wx
import webbrowser as web
APP_TITLE = u'decryption software of Caesars upraded version(vip)'
class mainFrame(wx.Frame):
def __init__(self,parent):
wx.Frame.__init__(self,parent,-1,APP_TITLE)
self.SetSize((1020,750)) #Determine window size
'''Create text prompt'''
wx.StaticText(self, -1, u'Letter mapping table', pos=(0, 50), size=(150,-1), style=wx.ALIGN_RIGHT)
wx.StaticText(self, -1, pos=(40, 80), size=(150, -1), style=wx.ALIGN_RIGHT)
self.tip = wx.StaticText(self, -1, u'*Please modify the second line of letter mapping table', pos=(600, 80), size=(350, -1), style=wx.ST_NO_AUTORESIZE)
wx.StaticText(self, -1, u'plaintext', pos=(0, 120), size=(150, -1), style=wx.ALIGN_RIGHT)
wx.StaticText(self, -1, u'ciphertext', pos=(0, 350), size=(150, -1), style=wx.ALIGN_RIGHT)
self.tip.SetForegroundColour('red') #Determine font color
self.SetBackgroundColour('#A6FFA6') #Determine page background color
# Create four text boxes
self.tc1 = wx.TextCtrl(self, -1, '', pos=(180, 50), size=(400, -1), name='TC01', style=wx.ALIGN_LEFT)
self.tc2 = wx.TextCtrl(self, -1, '', pos=(180, 80), size=(400, -1), name='TC02'