Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/sphinxext/mathmpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def latex2html(node, source):
fontset = node['fontset']
fontsize = node['fontsize']
name = 'math-{}'.format(
hashlib.md5(f'{latex}{fontset}{fontsize}'.encode()).hexdigest()[-10:])
hashlib.sha256(f'{latex}{fontset}{fontsize}'.encode()).hexdigest()[-10:])

destdir = Path(setup.app.builder.outdir, '_images', 'mathmpl')
destdir.mkdir(parents=True, exist_ok=True)
Expand Down
12 changes: 5 additions & 7 deletions lib/matplotlib/testing/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,20 @@ def get_cache_dir():


def get_file_hash(path, block_size=2 ** 20):
md5 = hashlib.md5()
sha256 = hashlib.sha256()
with open(path, 'rb') as fd:
while True:
data = fd.read(block_size)
if not data:
break
md5.update(data)
sha256.update(data)

if Path(path).suffix == '.pdf':
md5.update(str(mpl._get_executable_info("gs").version)
.encode('utf-8'))
sha256.update(str(mpl._get_executable_info("gs").version).encode('utf-8'))
elif Path(path).suffix == '.svg':
md5.update(str(mpl._get_executable_info("inkscape").version)
.encode('utf-8'))
sha256.update(str(mpl._get_executable_info("inkscape").version).encode('utf-8'))

return md5.hexdigest()
return sha256.hexdigest()


class _ConverterError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_basefile(cls, tex, fontsize, dpi=None):
Return a filename based on a hash of the string, fontsize, and dpi.
"""
src = cls._get_tex_source(tex, fontsize) + str(dpi)
filehash = hashlib.md5(src.encode('utf-8')).hexdigest()
filehash = hashlib.sha256(src.encode('utf-8')).hexdigest()
filepath = Path(cls._texcache)

num_letters, num_levels = 2, 2
Expand Down