如何加密字符串,然后将其转换回原始状态?

时间:2018-08-08 23:32:08

标签: python-3.x

我想制作一个密码存储程序,该程序会吐出一个随机密码,然后将其加密以存储在文本文件中。然后,我将可以在另一个程序中输入加密的表格并获得原始密码以供使用。

我将在下面添加当前代码:

import string
from random import *
import pyperclip

characters = string.ascii_letters + string.punctuation  + string.digits
password =  "".join(choice(characters) for x in range(randint(16, 32)))

def mess_up_pass(password):
    messed = password
    # This is where I am trying to encrypt or ‘mess up' the password

def get_orig(messed):
    # This is where I would like to take the messed up password and spit out the original form
    return # ???

with open('pass.txt', 'a') as x:
    x.write("\n")
    x.write(input("What is the service? ") + ": ")
    x.write(" " + password)
    x.write("\n")

0 个答案:

没有答案