python加密程序_Python自动加密程序

这里有一个简单的加密和解密脚本,如果你想使用它。密码部分可以省略,也可以保留。装载杆也是如此。加载条在第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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值