md5.hexdigest() converting unicode string to ascii
From: uebertester (mgibson_at_tripwire.com)
Date: 04/16/04
- Next message: Roy Smith: "Re: CamelCase versus wide_names (Prothon)"
- Previous message: Roy Smith: "Re: Difficulty Finding Python Developers"
- Next in thread: Krzysztof Stachlewski: "Re: md5.hexdigest() converting unicode string to ascii"
- Reply: Krzysztof Stachlewski: "Re: md5.hexdigest() converting unicode string to ascii"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 15 Apr 2004 15:50:00 -0700
I'm trying to get a MD5 hash of a registry key value on Windows 2000
Server. The registry value is a string which is stored as a unicode
string. I can get the registry key value and pass it to md5 via
update(), however, hexdigest() returns a hash value for the ascii
equivalent of the unicode string. Not the hash of the unicode string
itself. I've verified this by creating a text file containing an
ascii form of the string and one containing a unicode form of the
string. The hash returned by md5.hexdigest() matches that when I run
md5sum on the ascii file.
Here is the code I'm using:
import _winreg
from md5 import md5
x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
y= _winreg.OpenKey(x,
r"SOFTWARE\Microsoft\Windows\CurrentVersion\URL\DefaultPrefix")
sValue = _winreg.QueryValueEx(y,"")
print sValue
m = md5()
m.update(unicode(sValue[0]))
MD5 = m.hexdigest()
print "%s \n%d" % (sValue[0], sValue[1])
print MD5
_winreg.CloseKey(y)
_winreg.CloseKey(x)
Any help would be appreciated.
- Next message: Roy Smith: "Re: CamelCase versus wide_names (Prothon)"
- Previous message: Roy Smith: "Re: Difficulty Finding Python Developers"
- Next in thread: Krzysztof Stachlewski: "Re: md5.hexdigest() converting unicode string to ascii"
- Reply: Krzysztof Stachlewski: "Re: md5.hexdigest() converting unicode string to ascii"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|