Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfbcdbb

Browse files
committed
A crypt algorithm may not be available by returning None.
1 parent daa5799 commit cfbcdbb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/crypt.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,10 @@ def crypt(word, salt=None):
5353
METHOD_SHA256 = _Method('SHA256', '5', 16, 63)
5454
METHOD_SHA512 = _Method('SHA512', '6', 16, 106)
5555

56-
methods = [METHOD_SHA512, METHOD_SHA256, METHOD_MD5, METHOD_CRYPT]
57-
methods[:-1] = [m for m in methods[:-1] if len(crypt('', m)) == m.total_size]
56+
methods = []
57+
for _method in (METHOD_SHA512, METHOD_SHA256, METHOD_MD5):
58+
_result = crypt('', _method)
59+
if _result and len(_result) == _method.total_size:
60+
methods.append(_method)
61+
methods.append(METHOD_CRYPT)
62+
del _result, _method

0 commit comments

Comments
 (0)