{"id":18135538,"url":"https://github.com/whitfin/siphash-java","last_synced_at":"2025-08-17T01:34:00.959Z","repository":{"id":57729988,"uuid":"49246233","full_name":"whitfin/siphash-java","owner":"whitfin","description":"SipHash in Java; zero-allocation and streaming implementations","archived":false,"fork":false,"pushed_at":"2020-10-06T22:22:13.000Z","size":27,"stargazers_count":35,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-25T12:26:02.988Z","etag":null,"topics":["hashing","siphash","streaming","zero-allocation"],"latest_commit_sha":null,"homepage":"https://javadoc.io/doc/io.whitfin/siphash","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whitfin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-08T03:13:26.000Z","updated_at":"2025-07-17T01:48:06.000Z","dependencies_parsed_at":"2022-09-07T20:23:46.609Z","dependency_job_id":null,"html_url":"https://github.com/whitfin/siphash-java","commit_stats":null,"previous_names":["zackehh/siphash-java"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/whitfin/siphash-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsiphash-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsiphash-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsiphash-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsiphash-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whitfin","download_url":"https://codeload.github.com/whitfin/siphash-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsiphash-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270796216,"owners_count":24647319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hashing","siphash","streaming","zero-allocation"],"created_at":"2024-11-01T14:08:09.983Z","updated_at":"2025-08-17T01:34:00.926Z","avatar_url":"https://github.com/whitfin.png","language":"Java","readme":"# SipHash\n\n[![Build Status](https://travis-ci.org/whitfin/siphash-java.svg?branch=master)](https://travis-ci.org/whitfin/siphash-java) [![Coverage Status](https://coveralls.io/repos/whitfin/siphash-java/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/whitfin/siphash-java?branch=master)\n\nA Java implementation of the SipHash cryptographic hash family. Supports any variation, although defaults to the widely used SipHash-2-4. This library offers both a zero-allocation implementation, along with a streaming digest.\n\nThis library was heavily influenced by [veorq's C implementation](https://github.com/veorq/siphash) and [Forward C\u0026C's reference implementation](http://www.forward.com.au/pfod/SipHashJavaLibrary/) - I just decided it was time a Java implementation of SipHash made it onto Maven :).\n\n## Setup\n\n`siphash` is available on Maven central, via Sonatype OSS:\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.whitfin\u003c/groupId\u003e\n    \u003cartifactId\u003esiphash\u003c/artifactId\u003e\n    \u003cversion\u003e2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\nThere are three main ways to use this library, and the appropriate choice will depend on your use case. For further usage, please visit the [documentation](http://www.javadoc.io/doc/io.whitfin/siphash).\n\n### Zero Allocation\n\nThe fastest use of this algorithm is to simply call `SipHasher.hash/2` which will call a zero-allocation implementation of the SipHash algorithm. This implementation should be used in most cases; specifically cases where you have frequently differing seed keys.\n\n```java\n// specify the key and data pair\nString key = \"0123456789ABCDEF\".getBytes();\nString data = \"my-input\".getBytes();\n\n// hash using default compression (2-4)\nlong hash1 = SipHasher.hash(key, data);\n\n// you can also specify compression rounds\nlong hash2 = SipHasher.hash(key, data, 2, 4);\n```\n\n### Contained Hashing\n\nThis is an optimized implementation for cases where you have a single key (such as a hash table). In these cases, the seed values can be precomputed and re-used, rather than calculating them repeatedly on each call to hash. Although the initial call to create a container uses an allocation, there are no other allocations inside the container.\n\n\n```java\n// create a container from our key\nString key = \"0123456789ABCDEF\".getBytes();\nSipHasherContainer container = SipHasher.container(key);\n\n// hash using default compression (2-4)\nlong hash1 = container.hash(data);\n\n// you can also specify compression rounds\nlong hash2 = container.hash(data, 2, 4);\n```\n\n### Streaming Digest\n\nThe final way to use the library is as a streaming digest; meaning that you can apply chunks of input as they become available. The advantage here is that you can hash input of unknown length. Naturally, this is slower than the alternatives and should only be used when necessary. A digest cannot be re-used; one must be created on a per-hash basis.\n\n```java\n// create a container from our key\nString key = \"0123456789ABCDEF\".getBytes();\nSipHasherStream hash = SipHasher.init(key);\n\n// update several times\nhash.update(\"chu\".getBytes());\nhash.update(\"nked\".getBytes());\nhash.update(\" string\".getBytes());\n\n// retrieve the final result\nlong result = hash.digest();\n```\n\n## Formatting\n\nBy default, as of v2.0.0, all hashes are returned as a `long`. However, you can use `SipHasher.toHexString/1` to convert a hash to a hexidecimal String value.\n\n```java\n// output will be padded (if necessary) to 16 bytes\nSipHasher.toHexString(-3891084581787974112L); // ca0017304f874620\nSipHasher.toHexString(   77813817455948350L); // 011473413414323e\n```\n\n## Contributing\n\nIf you wish to contribute (awesome!), please file an issue first! All PRs should pass `mvn clean verify` and maintain 100% test coverage.\n\n## Testing\n\nTests are run using `mvn`. I aim to maintain 100% coverage where possible (both line and branch).\n\nTests can be run as follows:\n\n```bash\n$ mvn clean verify\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitfin%2Fsiphash-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitfin%2Fsiphash-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitfin%2Fsiphash-java/lists"}