当前位置:网站首页>2021 autumn Information Security Experiment 1 (password and hiding technology)
2021 autumn Information Security Experiment 1 (password and hiding technology)
2022-07-03 12:33:00 【Android little white star】
Senior network security operation , Need to use python Of simplegui Implement a simple interface .
1. The first question is
Code :
import PySimpleGUI as sg # The abbreviation of the default library on the official website is sg, It is recommended to keep the same when using
# Define the layout of the window
layout = [[sg.Text(' Plaintext '),sg.InputText(key="value")],
[sg.Text(' encryption '), sg.InputText(key="value1")],
[sg.Text(' Decrypt '),sg.InputText(key="value2")],
[sg.Button(' encryption '),sg.Button(' Decrypt '),sg.Button(' Cancel ')]]
# Create a display window
window = sg.Window(' Ciphertext conversion ', layout)
# Encryption code
def add(string,k):
s=""
c=list(string)
for i in range(0,len(c)):
s=s+chr((ord(c[i])+k-ord('a'))%26+97)
return s
# Decryption code
def debug(string,k):
s=""
c=list(string)
for i in range(0,len(c)):
s=s+chr((ord(c[i])-k+26-ord('a'))%26+97)
return s
# Window response
while True:
event, values = window.read()
data = add(values['value'], 3)
sdata = debug(data, 3)
if event in (None, ' Cancel '):
break
elif event in (' encryption '):
window["value1"].update(data)
else:
window["value2"].update(sdata)
window.close()
effect :
The second question is
Code :
import PySimpleGUI as sg # The abbreviation of the default library on the official website is sg, It is recommended to keep the same when using
# Define the layout of the window
layout = [[sg.Text(' Plaintext '),sg.InputText(key="value")],
[sg.Text(' encryption '), sg.InputText(key="value1")],
[sg.Text(' Decrypt '),sg.InputText(key="value2")],
[sg.Button(' encryption '),sg.Button(' Decrypt '),sg.Button(' Cancel ')]]
# Create a display window
window = sg.Window(' Ciphertext conversion ', layout)
# encryption
def add(string):
s=""
c=list(string)
for i in range(0,len(c)):
s=s+chr(((ord(c[i])-ord('a'))*3+5)%26+97)
return s
# Decrypt
def debug(string):
s=""
c=list(string)
for i in range(0,len(c)):
for j in range(0,3):
if ((ord(c[i])-ord('a')-5+26*j)%3)==0:
s=s+chr(int((ord(c[i])-ord('a')-5+26*j)/3+97))
break
return s
# Window response
while True:
event, values = window.read()
data = add(values['value'])
sdata = debug(data)
if event in (None, ' Cancel '):
break
elif event in (' encryption '):
window["value1"].update(data)
else:
window["value2"].update(sdata)
window.close()
effect :
边栏推荐
- 1-2 project technology selection and structure
- ES6 standard
- MySQL time zone solution
- Introduction to concurrent programming (II)
- SLF4J 日志门面
- PHP export word method (one MHT)
- [MySQL special] read lock and write lock
- 剑指Offer10- I. 斐波那契数列
- Sword finger offer03 Repeated numbers in the array [simple]
- Use of atomicinteger
猜你喜欢
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
Basic knowledge of OpenGL (sort it out according to your own understanding)
Php Export word method (One MHT)
Eureka自我保护
Integer string int mutual conversion
【附下载】密码获取工具LaZagne安装及使用
Self made pop-up input box, input text, and click to complete the event.
剑指Offer04. 二维数组中的查找【中等】
Wechat applet - basic content
剑指Offer03. 数组中重复的数字【简单】
随机推荐
[combinatorics] permutation and combination (example of permutation and combination)
225. Implement stack with queue
手机号码变成空号导致亚马逊账号登陆两步验证失败的恢复网址及方法
Self made pop-up input box, input text, and click to complete the event.
RedHat5 安装Socket5代理服务器
[combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
Basic knowledge of OpenGL (sort it out according to your own understanding)
Introduction to concurrent programming (I)
Wechat applet - basic content
Pki/ca and digital certificate
Shardingsphere sub database and sub table < 3 >
Unicode encoding table download
Adult adult adult
SystemVerilog -- OOP -- copy of object
347. Top k high frequency elements
在网上炒股开户可以吗?资金安全吗?
The difference between lambda and anonymous inner class
Sword finger offer05 Replace spaces
记录自己vulnhub闯关记录
Shutter widget: centerslice attribute