Skip to main content

Hash Concatenation

Let's see how we concatenate hashes. We will use the SHA-256 hash function.

// hash1
sha256(file.pdf) = 52a0412dfafead865bc77b315c88b5de35edfc2d1b7142db1d589dcd687eee87

//hash2
sha256('hi') = 8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4

// hash3
sha256('hello') = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

// concatenated hash of hash1, hash2, and hash3
sha256(52a0412dfafead865bc77b315c88b5de35edfc2d1b7142db1d589dcd687eee878f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa42cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824) = a2038bf76dc5e600cf60f5875968e117565176787fe8569fe431adce817e8132

Using our API it's possible to submit multiple hashes in a single request. We store each individual hash and the concatenated result.

In the timestamp response of our API there is a field componentHashes. If it's not null, it contains the hashes that are concatenated. For a response that includes something like the following:

  "hash": "7305db9b2abccd706c256db3d97e5ff48d677cfe4d3a5904afb7da0e3950e1e2",
"componentHashes": [
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
"486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7"
],

We expect that the hash field is equal to the concatenated hash of the componentHashes.

sha256(2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7) = 7305db9b2abccd706c256db3d97e5ff48d677cfe4d3a5904afb7da0e3950e1e2