Hello everyone,
I have stumbled upon some unclarity regarding the calculation of document hashes in MHD (e.g. in ITI-65 transactions).
By my simple understanding so far, I would expect the hash to be calculated like this:
raw document bytes -(SHA-1)-> 160 hash bytes -(base64-encode)-> hash attribute string (28 characters)
However, at the currently ongoing EU connectathon, I have also encountered the following calculation method with a test partner, which, of course, leads to a different result:
raw document bytes -(SHA-1)-> 160 hash bytes -(hex-pretty-print)-> hex string (40 characters, encoded as 320 bytes in standard encodings) -(base64-encode)-> hash attribute string (56 characters)
This seems rather unnatural to me, since the hex formatting of the hash seems to fill a similar role as the base64 encoding already does:
making binary data human-readable and easily transferrable over many media. In examples provided by MHD, such as [1], hashes have been
calculated using the hex-display step. However, in the actual standard text of MHD, I haven't found any hints regarding the use of this
hex-display step, and in the only example with a hash in the base FHIR specification [2], no hex-display step has been inserted.
Can you advise me which of these two ways of calculating a document hash is the correct one?
Best regards,
Andreas
[1]
https://profiles.ihe.net/ITI/MHD/Bundle-ex-minimalProvideDocumentBundleSimple.json.html[2]
https://hl7.org/fhir/R4/documentreference-example.json.html