Python Forum
Beginner python password program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginner python password program
#1
print('\n')

print('uPass 1.0')




menu = input('Create - Y, Enter N: ')

if menu == 'Y' or menu == 'y':

    new_pass = input('Enter new password: ')
    file = open('uPass_pass.txt', 'w')
    file.write(new_pass)
    file.close()

    print_password = open('uPass_pass.txt', 'r')
    print(print_password.read())
    file.close()

elif menu == 'N' or menu == 'n':

    pass_input = input('Enter password: ')
    file = open('uPass_pass.txt', 'r')
    if pass_input == file:
        print('working')
    else:
        print('error')
This is my attempt at creating a program that lets the user create a password that is stored and can be called upon when the user enters the password and the program should determine if it is the correct or incorrect password. This program is very unfinished and in trial stages but I cannot figure out how to store the password in the text file that I have created. I am using PyCharm and have created the python file and text file names uPass_pass.txt. Any help is appreciated and I have tried to write this without help of other modules to challenge myself.
Reply
#2
Line 25. file is the file object, not the contents of the file. You need to read file contents like you do on line 18.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Hello, line 25 is missing .read()
if pass_input == file.read():
also user .lower() to convert automatically user input from uppercase to lowercase:
if menu.lower() == 'Y':
elif menu.lower() == 'N':
Reply
#4
You need the lower method on the input, not the target:

if menu.lower() == 'y':
    ...
elif menu.lower() == 'n':
    ...
menu == 'N'.lower() is the same as menu == 'n'.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
You might want to use the cryptography module instead of storing plain text passwords

https://gitlab.com/william.belanger/gmai...monitor.py
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  help me to make my password list in python >>> Oktay34riza 0 581 Dec-23-2022, 12:38 PM
Last Post: Oktay34riza
  What do i have to type in the IDLE shell to use this password manager program? MaartenRo 4 1,748 Jan-15-2022, 02:01 PM
Last Post: MaartenRo
  creating simplex tableau pivot program easy or difficult for a beginner in Python? alex_0 2 2,578 Mar-31-2021, 03:39 AM
Last Post: Larz60+
  Python: why skip the 'else' if password is wrong Max_988 1 1,965 Jun-20-2019, 12:19 AM
Last Post: woooee
  Beginner needs a little help with flashcard program Chrislw324 1 2,259 May-25-2019, 01:21 AM
Last Post: ichabod801
  Program regarding Password check need assistance Remediez 1 3,161 Jul-09-2018, 03:59 PM
Last Post: MasterGame
  Password Saver Program suitec 1 4,589 Aug-18-2017, 03:58 PM
Last Post: ichabod801
  Warning password insecure - Mysql backup with Python HyiikO 4 5,119 Jun-09-2017, 12:49 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020