当前位置:网站首页>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 :
边栏推荐
- Fundamentals of concurrent programming (III)
- Is it safe to open an account for online stock speculation? Who can answer
- Flutter 退出登录二次确认怎么做才更优雅?
- Develop plug-ins for idea
- 225. Implement stack with queue
- 雲計算未來 — 雲原生
- Dart: about Libraries
- wpa_ cli
- Cloud Computing future - native Cloud
- LeetCode 0556.下一个更大元素 III - 4步讲完
猜你喜欢

Wechat applet pages always report errors when sending values to the background. It turned out to be this pit!

(construction notes) ADT and OOP

QT OpenGL rotate, pan, zoom

Cloud Computing future - native Cloud

LeetCode 0556. Next bigger element III - end of step 4

剑指Offer06. 从尾到头打印链表
![Sword finger offer04 Search in two-dimensional array [medium]](/img/c4/002c951f8d914aaea4f4133685ebd1.png)
Sword finger offer04 Search in two-dimensional array [medium]

Summary of development issues

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

Fluent: Engine Architecture
随机推荐
(construction notes) learn the specific technology of how to design reusable software entities from three levels: class, API and framework
145. Post order traversal of binary tree
Redis
网上炒股开户安不安全?谁给回答一下
2.8 overview of ViewModel knowledge
01_ Using the concurrent tool class library, is thread safety safe
Shardingsphere sub database and sub table < 3 >
Introduction to concurrent programming (I)
Use of QT OpenGL camera
OpenGL index cache object EBO and lineweight mode
Is it OK to open an account for online stock speculation? Is the fund safe?
(构造笔记)GRASP学习心得
Atomic atomic operation
2.6 preliminary cognition of synergetic couroutines
How to deploy web pages to Alibaba cloud
Recovery of website address and method of Amazon account login two-step verification failure caused by mobile phone number becoming empty
剑指Offer03. 数组中重复的数字【简单】
The future of cloud computing cloud native
LeetCode 0556. Next bigger element III - end of step 4
Flutter: self study system