0

I want to make a password storage program that spits out a random password and then encrypt it to store in a text file. To which I will then be able to enter the encrypted form (in another program) and get the original password back to use.

I’ll add my current code below:

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")
Jason White
  • 39
  • 1
  • 1
  • 7
  • If you're using a strong encryption technique, you should not be able to go from encrypted password back to plaintext. The encrypting (or hashing) is one way. You only store the hashed value and when you want to check a password, you hash the input and compare to the stored value. Now there *do* exist hash algorithms that can be reversed, but these are not secure. – pault Aug 09 '18 at 01:47
  • Security is notoriously hard to do correctly, so I wouldn't use this program for actual passwords. But if you want to make it just for fun practice, you can look at simple (and insecure) ciphers in Cracking Codes with Python or the pycrypto module: https://pypi.org/project/pycrypto/ BUT I REPEAT: DO NOT USE YOUR PROGRAM FOR ACTUAL PASSWORDS. – Al Sweigart Aug 21 '18 at 22:07

0 Answers0