Re: [Tutor] forcing hashlib to has string variables

2010-09-12 Thread Rance Hall
On Sun, Sep 12, 2010 at 2:29 PM, Dave Angel wrote: >  On 2:59 PM, Rance Hall wrote: > Convert the string to bytes.  If the string is ASCII, you can simply use the > bytes() function.  If not, you may need to specify an encoding. Thanks Dave, this is what I needed, I looked in the function refer

Re: [Tutor] forcing hashlib to has string variables

2010-09-12 Thread Dave Angel
On 2:59 PM, Rance Hall wrote: Luke: On python3.1 I get the following error using your (untested) two line snippet: TypeError: Unicode-objects must be encoded before hashing If I add the b back into the mix, I get a hash with no error messages. But I still can't quite figure out how to get th

Re: [Tutor] forcing hashlib to has string variables

2010-09-12 Thread Dave Angel
On 2:59 PM, Rance Hall wrote: Everybody knows you don't store plain text passwords in a database, you store hashes instead consider: userpass = getpass.getpass("User password? ") encuserpass = hashlib.md5() encuserpass.update(userpass) del userpass Now the documentation clearly states th

Re: [Tutor] forcing hashlib to has string variables

2010-09-12 Thread Luke Paireepinart
Ah, it works differently on py3 i guess. Py2 was pretty lax with string handling. I would suggest researching Unicode encode functions rather than looking at the hashlib for info. There is probably a string.encode or something like that. - Sent from a mobile device w

Re: [Tutor] forcing hashlib to has string variables

2010-09-12 Thread Rance Hall
Luke: On python3.1 I get the following error using your (untested) two line snippet: TypeError: Unicode-objects must be encoded before hashing If I add the b back into the mix, I get a hash with no error messages. But I still can't quite figure out how to get the variable contents into the hash

Re: [Tutor] forcing hashlib to has string variables

2010-09-12 Thread Luke Paireepinart
This is how I use it (untested) Import hashlib Print hashlib.md5("somestr").hexdigest() Works fine without using binary string. On Sep 12, 2010, at 1:19 PM, Rance Hall wrote: > Everybody knows you don't store plain text passwords in a database, > you store hashes instead > > consider: > > us