techwithtim / 5-Python-Projects-For-Beginners

415 stars 235 forks source link

Error in Password Manager #15

Closed rewaj56 closed 1 year ago

rewaj56 commented 1 year ago

Traceback (most recent call last): File "e:\Python\Password manager\password-manager.py", line 18, in fer = Fernet(key) ^^^^^^^^^^^ File "C:\Users\proto\AppData\Local\Programs\Python\Python311\Lib\site-packages\cryptography\fernet.py", line 39, in init raise ValueError( ValueError: Fernet key must be 32 url-safe base64-encoded bytes. PS E:\Python\Password manager>

Anybody knows a fix ?

rewaj56 commented 1 year ago

Just realized, I needed to run the write_key() function once, but another error arises after that

Traceback (most recent call last): File "e:\Python\Password manager\password-manager.py", line 46, in view() File "e:\Python\Password manager\password-manager.py", line 26, in view user, passw = data.split("|") ^^^^^^^^^^^ ValueError: not enough values to unpack (expected 2, got 1)

rewaj56 commented 1 year ago

After some analyzing of my code, here's the fix to my fore-mentioned issue: Before, my passwords.txt was:

abcdef|gAAAAABjlD_iEF-DOPjRTILWhI-p9HqfA1er2sURdfZ50ex_lPyo2o0JW9TGN8hRcLFB76f_62KrH-mAEw5bW84gAEPf8D974g== Notice the empty first line

But when I remove that empty first line in my passwords.txt file, my code ran fine. I hope it was helpful !