summaryrefslogtreecommitdiff
path: root/passlib/utils
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-03-10 16:43:05 -0500
committerEli Collins <elic@assurancetechnologies.com>2012-03-10 16:43:05 -0500
commit929d2168c5119c4b9b401e0ece4a39bf8b944b08 (patch)
treebbe311ed8fa8cccd397166838fe6ccf488c7e326 /passlib/utils
parent557d17ba4e0123bce7e1659002270aa8dedb2f24 (diff)
downloadpasslib-929d2168c5119c4b9b401e0ece4a39bf8b944b08.tar.gz
added support for Cisco PIX & Type 7 hashes
* Cisco Type 5 appears to be same as md5_crypt * added requires_user=False support to HandlerCase * added more through salt-generation test (since cisco_pix has only 4 bits of salt) * added HandlerCase test to ensure user is used as salt
Diffstat (limited to 'passlib/utils')
-rw-r--r--passlib/utils/compat.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/passlib/utils/compat.py b/passlib/utils/compat.py
index 8523cc5..6bf8c50 100644
--- a/passlib/utils/compat.py
+++ b/passlib/utils/compat.py
@@ -159,6 +159,10 @@ if PY3:
def belem_ord(elem):
return elem
+ def biter_ints(s):
+ assert isinstance(s, bytes)
+ return s
+
else:
def uascii_to_str(s):
assert isinstance(s, unicode)
@@ -183,6 +187,10 @@ else:
belem_ord = ord
+ def biter_ints(s):
+ assert isinstance(s, bytes)
+ return (ord(c) for c in s)
+
_add_doc(uascii_to_str, "helper to convert ascii unicode -> native str")
_add_doc(bascii_to_str, "helper to convert ascii bytes -> native str")
_add_doc(str_to_uascii, "helper to convert ascii native str -> unicode")
@@ -196,6 +204,8 @@ _add_doc(str_to_bascii, "helper to convert ascii native str -> bytes")
# belem_ord -- function to convert byte element to integer -- a noop under PY3
+_add_doc(biter_ints, "helper to iterate over byte values in byte string")
+
#=============================================================================
# iteration helpers
#
@@ -233,6 +243,14 @@ else:
def itervalues(d):
return d.itervalues()
+if PY_MAX_25:
+ def next(itr):
+ "compat wrapper for next()"
+ # NOTE: omits support for 'default' arg
+ return itr.next()
+else:
+ next = builtins.next
+
#=============================================================================
# introspection
#=============================================================================