这里有一个简单的加密和解密脚本,如果你想使用它。密码部分可以省略,也可以保留。装载杆也是如此。加载条在第1-4行,密码在最后9行。如果你真的拿出了密码,一定要叫start。您还需要通过pip安装tqdm。在import time
from tqdm import *
for i in tqdm(range(1000)):
time.sleep(0.001)
def encrypt(some_string):
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
cipher = 'bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA'
encryption = ''
for char in some_string:
if(alphabet.find(char) == -1):
encryption = encryption + char
else:
position = alphabet.index(char)
encryption = encryption + cipher[position]
return encryption
def decrypt(some_string):
cipher = 'bcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZa'
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
decryption = ''
for char in some_string:
if(cipher.find(char) == -1):
decryption = decryption + char
else:
position = cipher.index(char)
decryption = decryption + alphabet[position]
return decryption
def restart():
print('Would you like to restart.')
print('1: Yes.')
print('2: No.')
c = float(input('Type a 1 or a 2: '))
if c == 1:
print('Ok you can restart.')
start()
if c == 2:
print('Sorry to see you leave.')
quit()
else:
print('Invalid response.')
restart()
def start():
print('1: Encryption')
print('2: Decryption')
e = float(input('Type a 1 or a 2: '))
if e == 1:
print('Type your message here.')
e = str(input('Enter message to encrypt: '))
print(encrypt(e))
restart()
if e == 2:
print('Type your messed up message here.')
e = str(input('Enter your messed up message: '))
print(decrypt(e))
restart()
else:
print('Please type a 1 or a 2.')
start()
def password():
a = float(input('Enter the correct password please: '))
if a == 5194703:
print('Correct!')
start()
else:
print('Invalid Password, try again!')
password()
password()