diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2011-04-05 18:22:33 -0400 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2011-04-05 18:22:33 -0400 |
| commit | 21ccf3d91af4f341dcfd9d2178038d3145226cb1 (patch) | |
| tree | 6d2daaf7bed633876b53ed5ad73c04ae3ba523bd | |
| parent | 51285559659a76755649bc239b3ea0c24bfedf1d (diff) | |
| download | passlib-21ccf3d91af4f341dcfd9d2178038d3145226cb1.tar.gz | |
passlib.utils.md4: use native hashlib md4 support if available
| -rw-r--r-- | passlib/utils/md4.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/passlib/utils/md4.py b/passlib/utils/md4.py index 8695bd8..0981a66 100644 --- a/passlib/utils/md4.py +++ b/passlib/utils/md4.py @@ -7,8 +7,6 @@ implementated based on rfc at http://www.faqs.org/rfcs/rfc1320.html """ -#TODO: check for libssl support via hashlib.new("md4"), - #========================================================================= #imports #========================================================================= @@ -226,5 +224,19 @@ class md4(object): #========================================================================= #========================================================================= +#check if hashlib provides accelarated md4 +#========================================================================= +import hashlib +try: + hashlib.new("md4") +except ValueError: + del hashlib +else: + #overwrite md4 class w/ hashlib wrapper + def md4(content=None): + "wrapper for hashlib.new('md4')" + return hashlib.new('md4', content or '') + +#========================================================================= #eof #========================================================================= |
