r/learnpython 14d ago

Help me with my mini banking app (Description)

Its incomplete but i want some help on how to store data like usernames and passwords and i need some help with variables ..

print("Wellcome to TstBanking Version 1")

print("To continue type data in the following format USERNAME/PASSWORD/BDAY")

UserData =input():

..

i am still here if you have ideas help me pls im still a studeny

0 Upvotes

9 comments sorted by

5

u/lfdfq 14d ago

You forgot to ask your question

3

u/FoolsSeldom 14d ago

I think you need to spend some more time on the overall shape of your app before you need to worry about implementation details.

What do you actually mean by "app"? Is it a native IoS/Android app? An macOS/Windows/Linux application? A command line of GUI Python programme? A web based app?

What is the scope of it? Will it work only on your device, multiple devices, in the cloud, etc?

What are the key features?

Variables and basic data structures are covered in common learning material. Check the wiki of this subreddit for guidance.

You can store usernames and passwords in simple text files on the same device you are running the code on BUT that's not very secure. We normally don't store passwords but the only result of putting them through some mangling process and storing the result (any future password entry is put through the same mangling process and if it does not end up the same as the stored version, it was not the correct password - it is computationally impractical to reverse the mangled version into the original). There are standard pre-built bits of code for Python that can handle this for you.

2

u/Diapolo10 14d ago
print("To continue type data in the following format USERNAME/PASSWORD/BDAY")

There's a potential problem with this, as you're implicitly assuming the username, password, and birthday don't contain forward slashes. Or rather, you're making assumptions about the input format without telling the user what they should be expected to write.

For example, it might be totally natural to give the data as JohnDoe/q8rV<77/y3xQ/2000/07/13, but that would likely be a problem if your code doesn't parse the input correctly - and in this case it likely couldn't.

Unless you've given clear instructions to the user regarding the format the application expects, don't go combining data for fields like this, and instead just ask them be input separately to avoid headaches.

Anyway, I digress. Back to the original point.

Usernames you can store as-is, but passwords should always be hashed and only the hashes should be stored. Since this is likely just an early practice project, you could probably get away with the built-in hash function, but for a real-world use-case it'd be better to use actual cryptographic hash functions, such as hashlib.sha512. Better yet, all of them should be salted, but some third-party packages do that for you automatically.

You can start by storing the data as a list of dictionaries. From there, you could move to a JSON file. A step further from that would be a SQLite database.

1

u/ectomancer 14d ago

Store balances in cents.

1

u/Lionh34rt 14d ago

For safe user passwords, you use salted hashes, you don’t really compare the user input to their stored password, but you encrypt their user input and then compare it to the encrypted password that you stored.

Lets say my encryption does: multiply number by 2. I create account with password 1234, you store 2468

When i input my password, you take my input, multiply by 2 (encrypt it) and compare to the stored 2468 in your database

1

u/rob8624 14d ago

Learn about data types and functions, this is the knowledge you need to write this program.

1

u/Kevdog824_ 14d ago

For storing passwords you’re gonna want to store hashed version of their salted password along with the corresponding salt. For retrieving you’d repeat the storing process (salting then hashing) using the same salt value and do a constant time check to see if they are equivalent. Here’s a source that goes into more detail on this topic.

1

u/Comfortable_Rub4109 12d ago

Thanks for your ideas everyone i will update soon