Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c28e539

Browse files
committed
Replace md5() with sha256() for hashing
For FIPS[0] related installation, the MD5 modules are unavailable, to the tune of md5() raising an exception. Using sha256() from the same hashlib passes the same `make test` and is now FIPS compliant. [0] http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140val-all.htm
1 parent 06b962c commit c28e539

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/markdown2.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@
102102
import sys
103103
import re
104104
import logging
105-
try:
106-
from hashlib import md5
107-
except ImportError:
108-
from md5 import md5
105+
from hashlib import sha256
109106
import optparse
110107
from random import random, randint
111108
import codecs
@@ -145,7 +142,7 @@ def reversed(sequence):
145142

146143
SECRET_SALT = bytes(randint(0, 1000000))
147144
def _hash_text(s):
148-
return 'md5-' + md5(SECRET_SALT + s.encode("utf-8")).hexdigest()
145+
return 'sha256-' + sha256(SECRET_SALT + s.encode("utf-8")).hexdigest()
149146

150147
# Table of hash values for escaped characters:
151148
g_escape_table = dict([(ch, _hash_text(ch))

0 commit comments

Comments
 (0)