https://github.com/moznion/metro-zig
MetroHash library for Zig
https://github.com/moznion/metro-zig
metrohash zig ziglang
Last synced: 8 months ago
JSON representation
MetroHash library for Zig
- Host: GitHub
- URL: https://github.com/moznion/metro-zig
- Owner: moznion
- License: other
- Created: 2022-08-10T07:49:46.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T05:42:21.000Z (over 2 years ago)
- Last Synced: 2025-01-31T07:34:19.530Z (over 1 year ago)
- Topics: metrohash, zig, ziglang
- Language: Zig
- Homepage:
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MetroHash for Zig [](https://github.com/moznion/metro-zig/actions/workflows/test.yaml)
[MetroHash](http://www.jandrewrogers.com/2015/05/27/metrohash/) library for [Zig](https://ziglang.org/).
This library provides 64-bit and 128-bit MetroHash hashing functions.
## Synopsis
### 64-bit Hash
```zig
var data = [_]u8{
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 48, 49, 50,
};
const seed: u64 = 1;
const hash: u64 = hash64(data[0..], seed);
```
### 128-bit Hash
```zig
var data = [_]u8{
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 48, 49, 50,
};
const seed: u64 = 1;
const hash: u128 = hash128(data[0..], seed);
```
## How to build and test
```
$ git submodule init && git submodule update
$ zig build test
```
## Note
This implementation is based on [jandrewrogers/MetroHash](https://github.com/jandrewrogers/MetroHash) and [dgryski/go-metro](https://github.com/dgryski/go-metro).
## License
MIT
## Author
moznion ()