[Tutor] hashlib problems

Luke Paireepinart rabidpoobear at gmail.com
Fri Sep 10 22:12:57 CEST 2010


In general, you shouldn't even hint at the possibility of there being a bug in the code unless you have test cases and a patch handy. Especially something as widely used as hashlib. It  gives An air of arrogance about your post, whether you intend it or not.
I think your issue got resolved already, just thought it might help to have a bit of an explication about hacker culture.
See Eric raymond's how to ask questions the smart way for much more information.  Sad as it is, your initial impressions will actually govern how likely you are to get replies.

Food for thought!

Sent from my iPhone

On Sep 10, 2010, at 2:10 PM, Dave Angel <davea at ieee.org> wrote:

> 
> 
> On 2:59 PM, Rance Hall wrote:
>> Im wanting to use the builtin hashlib functions to encrypt passwords
>> before storing them in a database.
>> 
>> According to documentation on the python.org site it should be as simple as
>> 
>> import hashlib
>> 
>> hashname = hashlib.sha234  (or whatever other hash method you want
>> like md5 or whatever)
>> 
> You forgot the parentheses.  You also picked one that doesn't exist, so switch to sha256() or sha384().
>> hashname.update(b"test")  the b is for byte since the documentation
>> states that hashlib does not accept strings
>> 
>> hashname.hexdigest() or digest() will give you the hash encrypted
>> value.  (hexdigest will encode the output in hex for use in email and
>> string db storage)
>> 
>> 
>> My problem is that hashname.update results in a:
>> 
>> AttributeError:  'built_in_function_or_method' object has no attribute 'update'
>> 
>> I get this error in python 2 and python 3
>> 
>> I get it on multiple operating systems, so I dont understand whats
>> going wrong.  Either there is a bug in the module hashlib, or the
>> module changed and the docs don't keep up.
>> 
>> Either way I can not encrypt the password of my project for new users
>> till I figure out whats going on.
>> 
>> Your help much appreciated.
>> 
>> Rance
>> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list