Reputation: 15
Hi I'm a bit new to this and can't exactly figure out how to get it working.
Here is my current code:
import hashlib
def PasswordCreate():
password = input(str("Please enter a password next to this text"))
password = hashlib.md5()
password.update(password.encode('utf-8'))
return password.hexdigest()
PasswordCreate()
The error is:
AttributeError: '_hashlib.HASH' object has no attribute 'encode'
Upvotes: 1
Views: 2196
Reputation: 942
Hello Josh,
Try this code,
import hashlib
def PasswordCreate():
inputVar = input(str("Please enter a password next to this text: "))
password = hashlib.md5()
password.update(inputVar.encode("utf-8"))
return password.hexdigest()
# Create Variable for dipslay encoded value.
displayPass = PasswordCreate()
print "User Password is: ",displayPass
Upvotes: 1
Reputation: 436
As simple as I can put:
import hashlib
print(hashlib.md5(input().encode()).hexdigest())
Upvotes: 0
Reputation: 1108
import hashlib
def PasswordCreate():
user_in = input(str("Please enter a password next to this text"))
password = hashlib.md5()
password.update(user_in.encode("utf-8"))
return password.hexdigest()
PasswordCreate()
Just an issue in your variables. See user_in
in my code
Upvotes: 0
Reputation: 5454
Perhaps something like following:
import hashlib
def PasswordCreate():
password = raw_input(str("Please enter a password next to this text: "))
return hashlib.md5(password).hexdigest()
PasswordCreate()
Upvotes: 0