# macho: generalize parallel hasher; impl parallel MD5-like hash · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/79457fc76a61695560e6314246b0a8c21a7e2d2c)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 79457fc76a61695560e6314246b0a8c21a7e2d2c

Requested commit: 79457fc76a61695560e6314246b0a8c21a7e2d2c

Commit: 79457fc76a61695560e6314246b0a8c21a7e2d2c

Tree: 7a35a25f880c057e27098b240f8fac7e42b842eb

Author: Jakub Konka

Committer: Jakub Konka

## Message

```
macho: generalize parallel hasher; impl parallel MD5-like hash

By pulling out the parallel hashing setup from `CodeSignature.zig`,
we can now reuse it different places across MachO linker (for now;
I can totally see its usefulness beyond MachO, eg. in COFF or ELF too).
The parallel hasher is generic over actual hasher such as Sha256 or MD5.
The implementation is kept as it was.

For UUID calculation, depending on the linking mode:
* incremental - since it only supports debug mode, we don't bother with MD5
  hashing of the contents, and populate it with random data but only once
  per a sequence of in-place binary patches
* traditional - in debug, we use random string (for speed); in release,
  we calculate the hash, however we use LLVM/LLD's trick in that we
  calculate a series of MD5 hashes in parallel and then one an MD5 of MD5
  final hash to generate digest.

```

## Parents

- [ec40c6b28fb1612f401db3c43b68aba670327e2e](https://git.cafe/gitcafe/zig/commit/ec40c6b28fb1612f401db3c43b68aba670327e2e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/79457fc76a61695560e6314246b0a8c21a7e2d2c?format=markdown)
