diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2013-05-06 17:03:23 -0400 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2013-05-06 17:03:23 -0400 |
| commit | 306f9ba07c7832aeffac0ade60f0c55f51ac0959 (patch) | |
| tree | 8c0e2512586b8ba688eb5ccf7e61827fce833500 /admin | |
| parent | ba541d2760452509fd12a765c9b0fd5385fcdbc5 (diff) | |
| parent | 8bcfde1a73c7aac7ed9185804db272f13ea8cafb (diff) | |
| download | passlib-306f9ba07c7832aeffac0ade60f0c55f51ac0959.tar.gz | |
Merge password generation helpers into default (not completed, but will be before 1.7 release)
Diffstat (limited to 'admin')
| -rw-r--r-- | admin/benchmarks.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/admin/benchmarks.py b/admin/benchmarks.py index 0a6f0e7..d7c8a2e 100644 --- a/admin/benchmarks.py +++ b/admin/benchmarks.py @@ -17,8 +17,6 @@ sys.path.insert(0, os.curdir) # core from binascii import hexlify import logging; log = logging.getLogger(__name__) -import os -import warnings # site # pkg try: @@ -26,14 +24,14 @@ try: except ImportError: PasslibConfigWarning = None import passlib.utils.handlers as uh -from passlib.utils.compat import u, print_, unicode, next_method_attr +from passlib.utils.compat import u, print_, unicode # local #============================================================================= # benchmarking support #============================================================================= class benchmark: - "class to hold various benchmarking helpers" + """class to hold various benchmarking helpers""" @classmethod def constructor(cls, **defaults): @@ -149,7 +147,7 @@ OTHER = u("setecastronomy") #============================================================================= @benchmark.constructor() def test_context_from_path(): - "test speed of CryptContext.from_path()" + """test speed of CryptContext.from_path()""" path = sample_config_1p if CryptPolicy: def helper(): @@ -161,7 +159,7 @@ def test_context_from_path(): @benchmark.constructor() def test_context_update(): - "test speed of CryptContext.update()" + """test speed of CryptContext.update()""" kwds = dict( schemes = [ "sha512_crypt", "sha256_crypt", "md5_crypt", "des_crypt", "unix_disabled" ], @@ -180,7 +178,7 @@ def test_context_update(): @benchmark.constructor() def test_context_init(): - "test speed of CryptContext() constructor" + """test speed of CryptContext() constructor""" kwds = dict( schemes=[BlankHandler, AnotherHandler], default="another", @@ -194,7 +192,7 @@ def test_context_init(): @benchmark.constructor() def test_context_calls(): - "test speed of CryptContext password methods" + """test speed of CryptContext password methods""" ctx = CryptContext( schemes=[BlankHandler, AnotherHandler], default="another", @@ -214,7 +212,7 @@ def test_context_calls(): #============================================================================= @benchmark.constructor() def test_md5_crypt_builtin(): - "test test md5_crypt builtin backend" + """test test md5_crypt builtin backend""" from passlib.hash import md5_crypt md5_crypt.set_backend("builtin") def helper(): @@ -225,7 +223,7 @@ def test_md5_crypt_builtin(): @benchmark.constructor() def test_ldap_salted_md5(): - "test ldap_salted_md5" + """test ldap_salted_md5""" from passlib.hash import ldap_salted_md5 as handler def helper(): hash = handler.encrypt(SECRET, salt='....') @@ -235,7 +233,7 @@ def test_ldap_salted_md5(): @benchmark.constructor() def test_phpass(): - "test phpass" + """test phpass""" from passlib.hash import phpass as handler kwds = dict(salt='.'*8, rounds=16) def helper(): @@ -244,6 +242,16 @@ def test_phpass(): handler.verify(OTHER, hash) return helper +@benchmark.constructor() +def test_sha1_crypt(): + from passlib.hash import sha1_crypt as handler + kwds = dict(salt='.'*8, rounds=10000) + def helper(): + hash = handler.encrypt(SECRET, **kwds) + handler.verify(SECRET, hash) + handler.verify(OTHER, hash) + return helper + #============================================================================= # crypto utils #============================================================================= |
