当前位置:网站首页>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 :
边栏推荐
- Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
- wpa_ cli
- temp
- Lambda expression
- 网上炒股开户安不安全?谁给回答一下
- QT OpenGL texture map
- PHP export word method (one MHT)
- ES6 standard
- The future of cloud computing cloud native
- 225. Implement stack with queue
猜你喜欢

Socket TCP for network communication (I)

Sword finger offer07 Rebuild binary tree

Shutter widget: centerslice attribute

Flutter 退出登录二次确认怎么做才更优雅?

4000 word super detailed pointer

Develop plug-ins for idea

2.7 overview of livedata knowledge points

idea将web项目打包成war包并部署到服务器上运行

Sword finger offer06 Print linked list from end to end

Self made pop-up input box, input text, and click to complete the event.
随机推荐
Unicode查询的官方网站
阿里大于发送短信(用户微服务--消息微服务)
elastic_ L04_ introduction. md
Unicode encoding table download
Develop plug-ins for idea
temp
DEJA_VU3D - Cesium功能集 之 054-模拟火箭发射全过程
剑指Offer03. 数组中重复的数字【简单】
(construction notes) learning experience of MIT reading
(construction notes) grasp learning experience
Sword finger offer05 Replace spaces
OpenGL index cache object EBO and lineweight mode
Shardingsphere sub database and sub table < 3 >
Redis
Shell: basic learning
wpa_ cli
PHP get the file list and folder list under the folder
Redis notes 01: Introduction
repo Manifest Format
If you can't learn, you have to learn. Jetpack compose writes an im app (II)