Do you have extra good reason to call hashlib function with a variable
called password ?
If you simply want to hash user password, django provide a few
function for that job [1].
it's used like that:
>>> from django.contrib.auth.hashers import make_password, >>> check_password
>>> pwd = make_password("foobar")
>>> checkpassword("foobar", pwd)
Notice how you don't have to worry about thing like salt. Django take
care of that.
To answer your question, you are trying to concatenate
`hashlib.md5(force_bytes(password)).hexdigest()`, which is a str and
`force_bytes(salt)`, which is a bytes. You can add a str() aroung the
second part or a force_bytes around the first one.
[1] https://docs.djangoproject.com/en/1.9/topics/auth/passwords/
2016-06-23 17:09 GMT+02:00 <jorrit787@gmail.com>:
> As a follow-up question to this... this line gives the error "Can't convert
> 'bytes' object to str implicitly":
>
> vB_hash = hashlib.md5(hashlib.md5(force_bytes(password)).hexdigest() +
> force_bytes(salt)).hexdigest()
>
>
> Do I need to insert a str() somewhere?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c722dda1-009f-4bb0-b7a7-99bd9ffb2bbc%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
Cordialement, Coues Ludovic
+336 148 743 42
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTZvQzmGYSsFYfigodys7k%2BUsqwJ-UN5Wo1zY0rgWfTSGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment