filter.py: easy-fix to use sha1 instead of md5 if its usage prohibited by some systems following strict standards (like FIPS)

closes gh-1540
pull/1551/head
Serg G. Brester 2016-09-20 00:00:26 +02:00 committed by GitHub
parent fad953ade6
commit 1071db2256
1 changed files with 6 additions and 1 deletions

View File

@ -742,7 +742,12 @@ class FileFilter(Filter):
try:
import hashlib
md5sum = hashlib.md5
try:
md5sum = hashlib.md5
# try to use it (several standards like FIPS forbid it):
md5sum(' ').hexdigest()
except: # pragma: no cover
md5sum = hashlib.sha1
except ImportError: # pragma: no cover
# hashlib was introduced in Python 2.5. For compatibility with those
# elderly Pythons, import from md5