当前位置:网站首页>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 :
边栏推荐
猜你喜欢

Sword finger offer06 Print linked list from end to end
![[official MySQL document] deadlock](/img/2d/04e97d696f20c2524701888ea9cd10.png)
[official MySQL document] deadlock

Sword finger offer09 Implementing queues with two stacks
![[download attached] password acquisition tool lazagne installation and use](/img/21/eccf87ad9946d4177b600d96e17322.png)
[download attached] password acquisition tool lazagne installation and use

阿里大于发送短信(用户微服务--消息微服务)
![[ManageEngine] the role of IP address scanning](/img/dc/df353da0e93e4d936c39a39493b508.png)
[ManageEngine] the role of IP address scanning

Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?

LeetCode 0556.下一个更大元素 III - 4步讲完

Eureka self protection

云计算未来 — 云原生
随机推荐
Fluent: Engine Architecture
Eureka自我保护
Dart: About zone
Atomic atomic operation
2.7 overview of livedata knowledge points
Implement verification code verification
What is more elegant for flutter to log out and confirm again?
Jsup crawls Baidu Encyclopedia
DEJA_ Vu3d - 054 of cesium feature set - simulate the whole process of rocket launch
repo Manifest Format
剑指Offer05. 替换空格
【附下载】密码获取工具LaZagne安装及使用
232. Implement queue with stack
[combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
Swagger
225. Implement stack with queue
[MySQL special] read lock and write lock
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
Eureka self protection
4000字超详解指针