Skip to content

Commit b3c8383

Browse files
committed
'md5/sha1-
1 parent f7f8fb4 commit b3c8383

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

dash/_callback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def register_clientside_callback(
535535
if isinstance(clientside_function, str):
536536
namespace = "_dashprivate_clientside_funcs"
537537
# Create a hash from the function, it will be the same always
538-
function_name = hashlib.md5(clientside_function.encode("utf-8")).hexdigest()
538+
function_name = hashlib.sha256(clientside_function.encode("utf-8")).hexdigest()
539539

540540
inline_scripts.append(
541541
_inline_clientside_template.format(

dash/_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _concat(x):
142142
_id = x.component_id_str().replace(".", "\\.") + "." + x.component_property
143143
if x.allow_duplicate:
144144
if not hashed_inputs:
145-
hashed_inputs = hashlib.md5(
145+
hashed_inputs = hashlib.sha256(
146146
".".join(str(x) for x in inputs).encode("utf-8")
147147
).hexdigest()
148148
# Actually adds on the property part.
@@ -213,9 +213,9 @@ def run_command_with_process(cmd):
213213
proc.communicate()
214214

215215

216-
def compute_md5(path):
216+
def compute_hash(path):
217217
with io.open(path, encoding="utf-8") as fp:
218-
return hashlib.md5(fp.read().encode("utf-8")).hexdigest()
218+
return hashlib.sha256(fp.read().encode("utf-8")).hexdigest()
219219

220220

221221
def job(msg=""):

dash/development/_jl_components_generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def generate_toml_file(project_shortname, pkg_data):
416416
u = uuid.UUID(jl_dash_uuid)
417417

418418
package_uuid = uuid.UUID(
419-
hex=u.hex[:-12] + hashlib.md5(package_name.encode("utf-8")).hexdigest()[-12:]
419+
hex=u.hex[:-12] + hashlib.sha256(package_name.encode("utf-8")).hexdigest()[-12:]
420420
)
421421

422422
authors_string = (

dash/development/build_process.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import fire
99
import requests
1010

11-
from .._utils import run_command_with_process, compute_md5, job
11+
from .._utils import run_command_with_process, compute_hash, job
1212

1313
logger = logging.getLogger(__name__)
1414
coloredlogs.install(
@@ -97,7 +97,8 @@ def digest(self):
9797
logger.info("bundles in %s %s", folder, copies)
9898

9999
for copy in copies:
100-
payload[f"MD5 ({copy})"] = compute_md5(self._concat(folder, copy))
100+
# note md5 has been replaced with sha256, leaving string 'MD5 (hash)' as is because impacts are unclear
101+
payload[f"MD5 ({copy})"] = compute_hash(self._concat(folder, copy))
101102

102103
with open(self._concat(self.main, "digest.json"), "w", encoding="utf-8") as fp:
103104
json.dump(payload, fp, sort_keys=True, indent=4, separators=(",", ":"))

dash/long_callback/managers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def build_cache_key(self, fn, args, cache_args_to_ignore):
7373
# Call cache function
7474
hash_dict[f"cache_key_{i}"] = cache_item()
7575

76-
return hashlib.sha1(str(hash_dict).encode("utf-8")).hexdigest()
76+
return hashlib.sha256(str(hash_dict).encode("utf-8")).hexdigest()
7777

7878
def register(self, key, fn, progress):
7979
self.func_registry[key] = self.make_job_fn(fn, progress, key)
@@ -102,6 +102,6 @@ def _make_progress_key(key):
102102
def hash_function(fn, callback_id=""):
103103
fn_source = inspect.getsource(fn)
104104
fn_str = fn_source
105-
return hashlib.sha1(
105+
return hashlib.sha256(
106106
callback_id.encode("utf-8") + fn_str.encode("utf-8")
107107
).hexdigest()

0 commit comments

Comments
 (0)