mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Use SHA1 by default instead of MD5
This commit is contained in:
parent
73f2df76ce
commit
6198976edb
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue