Use SHA1 by default instead of MD5

This commit is contained in:
Bo Maryniuk 2016-02-12 16:47:07 +01:00
parent 73f2df76ce
commit 6198976edb

View file

@ -1979,7 +1979,7 @@ def safe_walk(top, topdown=True, onerror=None, followlinks=True, _seen=None):
yield top, dirs, nondirs
def get_hash(path, form='md5', chunk_size=65536):
def get_hash(path, form='sha1', chunk_size=65536):
'''
Get the hash sum of a file
@ -1989,10 +1989,10 @@ def get_hash(path, form='md5', chunk_size=65536):
``get_sum`` cannot really be trusted since it is vulnerable to
collisions: ``get_sum(..., 'xyz') == 'Hash xyz not supported'``
'''
try:
hash_type = getattr(hashlib, form)
except (AttributeError, TypeError):
hash_type = hasattr(hashlib, form) and getattr(hashlib, form) or None
if hash_type is None:
raise ValueError('Invalid hash type: {0}'.format(form))
with salt.utils.fopen(path, 'rb') as ifile:
hash_obj = hash_type()
# read the file in in chunks, not the entire file