I am trying to create a funtion in Python that makes a dictionary from all the words in a file and their corresponding encryption (that follows from the function encrypt_password). The funtion doesn't give an error, but it isn't printing the password dictionary as well. Where am I going wrong?
The input now looks like this:
import hashlib
def encrypt_password( passwd ):
"""Encrypt a plaintext password (a string). It returns the result.
This encryption is one-way only, meaning it is not easy (impossible) to decrypt
the encrypted password to find out the original plaintext password again."""
return hashlib.sha256( passwd.encode() ).hexdigest()
keys = open('words.txt').read().splitlines()
values = []
for i in keys:
e = encrypt_password(i)
values.append(e)
password = dict(zip(keys, values))
print(password)
Thanks in advance!
You have variables Passwords, password in different spellings. What does password refer to?
It seems like a typo: the passwords dictionary is first called 'Passwords' and next 'password'. Probably you meant:
passwords = dict(zip(keys, values))
print(passwords)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.