Skip to content

DataHash

general · scripts/general/DataHash.m

DATAHASH  MD5 / SHA digest of array or file (File Exchange compatible subset).

  H = DataHash (DATA)
  H = DataHash (DATA, METHOD)
  H = DataHash (DATA, OPT)

  METHOD is 'MD5' (default), 'SHA-1', 'SHA-256', 'SHA-384', or 'SHA-512'
  (hyphens optional; case-insensitive).

  OPT may be a struct with fields:
    Method  - digest algorithm (default 'MD5')
    Format  - 'hex' (default), 'HEX', or 'double' (uint8 digest bytes)
    Input   - 'array' (default), 'file', or 'ascii'

  Headless: uses Nexus __hash__ when present, else Java MessageDigest.
  Digests match MATLAB R2026a java.security.MessageDigest for the same
  byte payload (FIPS / RFC hex).