Changeset: 85197825581b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=85197825581b
Modified Files:
clients/python/monetdb/mapi2.py
Branch: Dec2011
Log Message:
Python client: also support RIPEMD160 hash algorithm if python lib does.
Unfortunately Python's hashlib.algorithms and dir(hashlib) is
"incomplete" in this regards and lists only algorithms which are
guaranteed to be supported. Yet more are actually implemented.
The patch moves the responsibility for checking whether RIPEMD160 (and
others) is supported to hashlib, retaining the NotSupportedError.
Signed off by Sjoerd.
diffs (31 lines):
diff --git a/clients/python/monetdb/mapi2.py b/clients/python/monetdb/mapi2.py
--- a/clients/python/monetdb/mapi2.py
+++ b/clients/python/monetdb/mapi2.py
@@ -176,21 +176,12 @@ class Server:
if protocol == '9':
algo = challenges[5]
- if algo == 'SHA512':
- password = hashlib.sha512(password).hexdigest()
- elif algo == 'SHA384':
- password = hashlib.sha384(password).hexdigest()
- elif algo == 'SHA256':
- password = hashlib.sha256(password).hexdigest()
- elif algo == 'SHA224':
- password = hashlib.sha224(password).hexdigest()
- elif algo == 'SHA1':
- password = hashlib.sha1(password).hexdigest()
- elif algo == 'MD5':
- password = hashlib.md5(password).hexdigest()
- else:
- raise NotSupportedError("The %s hash algorithm is not " +
- "supported" % algo)
+ try:
+ h = hashlib.new(algo)
+ h.update(password)
+ password = h.hexdigest()
+ except ValueError, e:
+ raise NotSupportedError(e.message)
elif protocol != "8":
raise NotSupportedError("We only speak protocol v8 and v9")
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list