passlib 1.7.1

This commit is contained in:
Jay Lee
2017-09-20 12:11:31 -04:00
parent 3bf5ffeb99
commit f383c45e6b
92 changed files with 36570 additions and 7258 deletions

View File

@@ -34,8 +34,8 @@ warn("the 'passlib.win32' module is deprecated, and will be removed in "
from binascii import hexlify
# site
# pkg
from passlib.utils.compat import b, unicode
from passlib.utils.des import des_encrypt_block
from passlib.utils.compat import unicode
from passlib.crypto.des import des_encrypt_block
from passlib.hash import nthash
# local
__all__ = [
@@ -46,7 +46,7 @@ __all__ = [
#=============================================================================
# helpers
#=============================================================================
LM_MAGIC = b("KGS!@#$%")
LM_MAGIC = b"KGS!@#$%"
raw_nthash = nthash.raw_nthash
@@ -59,7 +59,7 @@ def raw_lmhash(secret, encoding="ascii", hex=False):
# from being made w/o user explicitly choosing an encoding.
if isinstance(secret, unicode):
secret = secret.encode(encoding)
ns = secret.upper()[:14] + b("\x00") * (14-len(secret))
ns = secret.upper()[:14] + b"\x00" * (14-len(secret))
out = des_encrypt_block(ns[:7], LM_MAGIC) + des_encrypt_block(ns[7:], LM_MAGIC)
return hexlify(out).decode("ascii") if hex else out