code: def sha256_from_cache(filename, title, use_addnet_hash=False):
      hashes = (
          cache("hashes-addnet") if use_addnet_hash else cache("hashes")
      )
      ondisk_mtime = os.path.getmtime(filename)
  
      if title not in hashes:
          return None
  
      cached_sha256 = hashes[title].get("sha256", None)
      cached_mtime = hashes[title].get("mtime", 0)
  
      if ondisk_mtime > cached_mtime or cached_sha256 is None:
          return None
  
      return cached_sha256
  
file_path: stable-diffusion-webui/modules/hashes.py
imports: import hashlib
  import os.path
  from modules import shared
  import modules.cache
label_desc: Use image node_id 2 for calling a global function with example usage: sha256_from_cache(filename, title, use_addnet_hash) and returns: cached_sha256, None, None