Skip to content

Commit 9b7f94f

Browse files
authored
Merge pull request #18193 from daytonb/fips-compatible
Allow savefig to save SVGs on FIPS enabled systems #18192
2 parents 97fb361 + 47a0430 commit 9b7f94f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ID attribute of XML tags in SVG files now based on SHA256 rather than MD5
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Matplotlib generates unique ID attributes for various tags in SVG files.
5+
Matplotlib previously generated these unique IDs using the first 10
6+
characters of an MD5 hash. The MD5 hashing algorithm is not available in
7+
Python on systems with Federal Information Processing Standards (FIPS)
8+
enabled. Matplotlib now uses the first 10 characters of an SHA256 hash
9+
instead. SVG files that would otherwise match those saved with earlier
10+
versions of matplotlib, will have different ID attributes.

lib/matplotlib/backends/backend_svg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def _make_id(self, type, content):
452452
salt = mpl.rcParams['svg.hashsalt']
453453
if salt is None:
454454
salt = str(uuid.uuid4())
455-
m = hashlib.md5()
455+
m = hashlib.sha256()
456456
m.update(salt.encode('utf8'))
457457
m.update(str(content).encode('utf8'))
458458
return '%s%s' % (type, m.hexdigest()[:10])

0 commit comments

Comments
 (0)