将输入(密码)转换为 MD5
Converting a input (Password) into MD5
您好,我对此有点陌生,无法完全弄清楚如何让它发挥作用。
这是我当前的代码:
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()
错误是:
AttributeError: '_hashlib.HASH' object has no attribute 'encode'
可能如下所示:
import hashlib
def PasswordCreate():
password = raw_input(str("Please enter a password next to this text: "))
return hashlib.md5(password).hexdigest()
PasswordCreate()
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()
只是你的变量有问题。请参阅我的代码中的 user_in
尽可能简单:
import hashlib
print(hashlib.md5(input().encode()).hexdigest())
你好乔希,
试试这个代码,
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
您好,我对此有点陌生,无法完全弄清楚如何让它发挥作用。
这是我当前的代码:
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()
错误是:
AttributeError: '_hashlib.HASH' object has no attribute 'encode'
可能如下所示:
import hashlib
def PasswordCreate():
password = raw_input(str("Please enter a password next to this text: "))
return hashlib.md5(password).hexdigest()
PasswordCreate()
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()
只是你的变量有问题。请参阅我的代码中的 user_in
尽可能简单:
import hashlib
print(hashlib.md5(input().encode()).hexdigest())
你好乔希,
试试这个代码,
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