Mercurial > p > roundup > code
diff roundup/password.py @ 7228:07ce4e4110f5
flake8 fixes: whitespace, remove unused imports
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 18 Mar 2023 14:16:31 -0400 |
| parents | 4d83f9f751ff |
| children | 594b562ca99c |
line wrap: on
line diff
--- a/roundup/password.py Thu Mar 16 16:34:11 2023 -0400 +++ b/roundup/password.py Sat Mar 18 14:16:31 2023 -0400 @@ -43,9 +43,11 @@ _bempty = b"" _bjoin = _bempty.join + class ConfigNotSet(RoundupException): pass + def bchr(c): if bytes == str: # Python 2. @@ -127,9 +129,9 @@ block = xor_bytes(block, tmp) out += block return out[:keylen] - + def _pbkdf2_sha512(password, salt, rounds, keylen): - return _pbkdf2(password, salt, rounds, keylen, sha=sha512) + return _pbkdf2(password, salt, rounds, keylen, sha=sha512) def ssha(password, salt): @@ -172,6 +174,7 @@ raise ValueError("rounds must be positive number") return _pbkdf2_sha512(password, salt, rounds, keylen) + def pbkdf2(password, salt, rounds, keylen): """pkcs#5 password-based key derivation v2.0 @@ -237,7 +240,7 @@ rounds = config.PASSWORD_PBKDF2_DEFAULT_ROUNDS # if we are testing - if ("pytest" in sys.modules and + if ("pytest" in sys.modules and "PYTEST_CURRENT_TEST" in os.environ): if ("PYTEST_USE_CONFIG" in os.environ): rounds = config.PASSWORD_PBKDF2_DEFAULT_ROUNDS @@ -265,7 +268,7 @@ if sys.version_info[0] > 2: logger.critical( "encodePassword called without config.", - stack_info = True) + stack_info=True) else: import inspect, traceback where = inspect.currentframe()
