# Add Md5 and Sha1 hash functions · gitcafe/zig

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

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

Visibility: public

Requested revision: 51fdbf7f8c282c7b91a688c9069b363e90bedf6e

Requested commit: 51fdbf7f8c282c7b91a688c9069b363e90bedf6e

Commit: 51fdbf7f8c282c7b91a688c9069b363e90bedf6e

Tree: d509b0494776da54c78aa299d4679cf4f17180e0

Author: Marc Tiehuis

Committer: Marc Tiehuis

## Message

````
Add Md5 and Sha1 hash functions

Some performance comparisons to C.

We take the fastest time measurement taken across multiple runs.

The block hashing functions use the same md5/sha1 methods.

```
Cpu: Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
Gcc: 7.2.1 20171224
Clang: 5.0.1
Zig: 0.1.1.304f6f1d
```

See https://www.nayuki.io/page/fast-md5-hash-implementation-in-x86-assembly:

```
gcc -O2
    661 Mb/s
clang -O2
    490 Mb/s
zig --release-fast and zig --release-safe
    570 Mb/s
zig
    50 Mb/s
```

See https://www.nayuki.io/page/fast-sha1-hash-implementation-in-x86-assembly:

```
gcc -O2
    588 Mb/s
clang -O2
    563 Mb/s
zig --release-fast and zig --release-safe
    610 Mb/s
zig
    21 Mb/s
```

In short, zig provides pretty useful tools for writing this sort of
code. We are in the lead against clang (which uses the same LLVM
backend) with us being slower only against md5 with GCC.

````

## Parents

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

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