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

Shardingsphere sub database and sub table < 3 >

What is more elegant for flutter to log out and confirm again?
![[official MySQL document] deadlock](/img/2d/04e97d696f20c2524701888ea9cd10.png)
[official MySQL document] deadlock

Fluent: Engine Architecture

Develop plug-ins for idea

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

QT OpenGL rotate, pan, zoom

OpenGL index cache object EBO and lineweight mode

(construction notes) ADT and OOP

2.7 overview of livedata knowledge points
随机推荐
Sword finger offer10- I. Fibonacci sequence
OpenGL draws colored triangles
JVM memory model
Sword finger offer07 Rebuild binary tree
阿里大于发送短信(用户微服务--消息微服务)
Is it OK to open an account for online stock speculation? Is the fund safe?
剑指Offer05. 替换空格
Socket TCP for network communication (I)
[combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
Atomic atomic operation
2.6 preliminary cognition of synergetic couroutines
Fluent: Engine Architecture
102. Sequence traversal of binary tree
adb push apk
1-2 project technology selection and structure
02_ Lock the code, and don't let the "lock" become a worry
elastic_ L01_ summary
145. Post order traversal of binary tree
2.8 overview of ViewModel knowledge
TOGAF认证自学宝典V2.0