diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2012-04-10 14:21:16 -0400 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2012-04-10 14:21:16 -0400 |
| commit | d70e36e2fb1fc2b4e33d237c1a72cc6bc8802d52 (patch) | |
| tree | 96ccbbe5e755dfafb9f51ac63a99737ac8921808 /passlib/utils | |
| parent | d1aaad2741b18bf582e938c03230a84e158a7445 (diff) | |
| download | passlib-d70e36e2fb1fc2b4e33d237c1a72cc6bc8802d52.tar.gz | |
md5_crypt / sha2-crypt cleanup
* tried to clarify documentation & alg for builtin md5_crypt / sha2-crypt backends
* replaced regex parser in sha2-crypt with index-based one - less redundant, and should be faster.
Diffstat (limited to 'passlib/utils')
| -rw-r--r-- | passlib/utils/__init__.py | 9 | ||||
| -rw-r--r-- | passlib/utils/handlers.py | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py index e8e5b27..785afe0 100644 --- a/passlib/utils/__init__.py +++ b/passlib/utils/__init__.py @@ -481,6 +481,15 @@ def int_to_bytes(value, count): for s in irange(8*count-8,-8,-8) ) +def repeat_bytes(source, size): + "repeat or truncate <source> bytes, so it has length <size>" + cur = len(source) + if size <= cur: + return source[:size] + else: + mult = (size+cur-1)//cur + return (source*mult)[:size] + #============================================================================= # encoding helpers #============================================================================= diff --git a/passlib/utils/handlers.py b/passlib/utils/handlers.py index abd975d..ea8674c 100644 --- a/passlib/utils/handlers.py +++ b/passlib/utils/handlers.py @@ -113,7 +113,7 @@ def parse_mc3(hash, prefix, sep=_UDOLLAR, rounds_base=10, default_rounds=None, handler=None): """parse hash using 3-part modular crypt format. - this expects a hash of the format :samp:`{prefix}[{rounds}$]{salt}[${checksum}]`, + this expects a hash of the format :samp:`{prefix}[{rounds}]${salt}[${checksum}]`, such as sha1_crypt, and parses it into rounds / salt / checksum portions. tries to convert the rounds to an integer, and throws error if it has zero-padding. |
