{"id":19055197,"url":"https://github.com/sangupta/murmur","last_synced_at":"2025-04-05T22:10:02.960Z","repository":{"id":14558423,"uuid":"17274095","full_name":"sangupta/murmur","owner":"sangupta","description":"Pure Java implementations of Murmur hash algorithms","archived":false,"fork":false,"pushed_at":"2023-06-14T22:33:14.000Z","size":5768,"stargazers_count":73,"open_issues_count":4,"forks_count":21,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T21:07:55.551Z","etag":null,"topics":["java","murmur-hashes","murmur1","murmur2","murmur3","murmurhash3"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sangupta.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-28T03:34:59.000Z","updated_at":"2024-11-07T09:49:20.000Z","dependencies_parsed_at":"2024-11-16T02:04:42.025Z","dependency_job_id":"d1bc52db-bb06-4eb6-ba27-23609a036cb4","html_url":"https://github.com/sangupta/murmur","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangupta%2Fmurmur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangupta%2Fmurmur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangupta%2Fmurmur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangupta%2Fmurmur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sangupta","download_url":"https://codeload.github.com/sangupta/murmur/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406111,"owners_count":20933806,"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","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":["java","murmur-hashes","murmur1","murmur2","murmur3","murmurhash3"],"created_at":"2024-11-08T23:42:55.036Z","updated_at":"2025-04-05T22:10:02.923Z","avatar_url":"https://github.com/sangupta.png","language":"Java","readme":"# murmur\n\n[![Build Status](https://img.shields.io/travis/sangupta/murmur.svg)](https://travis-ci.org/sangupta/murmur)\n[![Coverage Status](https://img.shields.io/coveralls/sangupta/murmur.svg)](https://coveralls.io/github/sangupta/murmur?branch=master)\n[![license](https://img.shields.io/github/license/sangupta/murmur.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Maven Central](https://img.shields.io/maven-central/v/com.sangupta/murmur.svg)](https://maven-badges.herokuapp.com/maven-central/com.sangupta/murmur)\n\n`murmur` is a pure Java implementation of all Murmur hashes, namely, Murmur1, Murmur2 and Murmur3.\nThe library is a direct Java implementation of the C++ source code. Hash generation has been 100%\nunit tested against the hashes generated using the C++ code. The library should help in building \nout bloom filters, or to just compute the hash for checking sanity of data, as Murmur3 is much faster\nthan **MD5** and **SHA** computations.\n\nThe library is tested on the following JDK versions:\n\n* Oracle JDK 11\n* Oracle JDK 8\n* Open JDK 11\n* Open JDK 10\n* Open JDK 9\n* Open JDK 8\n\n## Why `murmur`?\n\n`murmur` was developed as we could not find pure Java implementations for `Murmur1` and `Murmur2` hashes.\nImplementations were available for `Murmur3` but for some of the legacy code that I maintain, I needed\nthe `Murmur1` and `Murmur2` hashes. Thus, I ported the original implementations.\n\nYou may find the hash inconsistent with [Google Guava]() library. The hash value is the same, it is\nthe endian-ness of the hash that makes it look different. Refer to [Issue #3](https://github.com/sangupta/murmur/issues/3)\nfor more details.\n\nTo convert the hash into `byte[]` or a `hex-string` you may use the following code:\n\n```java\n/**\n * Convert a given long value to byte-array.\n * \n * @param x the long value\n * \n * @return the byte[] array representation of it\n */\npublic static byte[] longToBytes(long x) {\n\tByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);\n\n\t// The ByteOrder.LITTLE_ENDIAN format matches the Google Guava toString() format\n\tbuffer.order(ByteOrder.LITTLE_ENDIAN);\n\n\tbuffer.putLong(x);\n\treturn buffer.array();\n}\n\n/**\n * Convert a byte-array to hex string.\n * \n * @param bytes the byte-array\n * \n * @return the hex string\n */\npublic static String bytesToHex(byte[] bytes) {\n\tchar[] hexChars = new char[bytes.length * 2];\n\tfor (int j = 0; j \u003c bytes.length; j++) {\n\t\tint v = bytes[j] \u0026 0xFF;\n\t\thexChars[j * 2] = hexArray[v \u003e\u003e\u003e 4];\n\t\thexChars[j * 2 + 1] = hexArray[v \u0026 0x0F];\n\t}\n\treturn new String(hexChars);\n}\n```\n\n## Features\n\n* Pure Java implementations of various Murmur hashes\n* 100% hash compatibility with original C++ code\n* No dependencies\n* Ultra light-weight, just 7KB in size\n\n## Performance\n\nThe `MurmurPerformanceTests.java` file contains tests to compute hashes of 1-million random type-4 UUIDs\nbetween various Murmur hashes, and `MD5`, `SHA-1`, `SHA-256`, and `SHA-512` hashes. \n\nThe results of a sample run on my dev machine are as under:\n\n```\nWindows\n-------\nIntel i7-2660 CPU @ 3.40Ghz\n16-GB RAM\nWindows 7, 64-bit, Service Pack 1\nOracle JDK 1.7.0_51 build 13, 64-bit Server VM\n\nOS X\n----\nIntel i7-4870HQ CPU @ 2.50GHz\n16-GB RAM\nmacOS Sierra 10.12.1\nOracle JDK 1.8.0_101 build 13, 64-bit Server VM\n```\n\n| Algorithm    | Time Taken Windows (ms) | Time Taken OSX (ms) |\n| :----------- | ----------------------: | ------------------: |\n| MD5          | 369                     | 338                 |\n| SHA-1        | 482                     | 415                 |\n| SHA-256      | 677                     | 642                 |\n| SHA-512      | 906                     | 782                 |\n| Murmur-1     | 143                     | 101                 |\n| Murmur-2     | 135                     | 123                 |\n| Murmur-2-64  | 102                     |  92                 |\n| Murmur-3     | 168                     | 119                 |\n| Murmur-3-128 | 160                     | 261                 |\n\n## Builds\n\n**1.0.0**\n\n* First release with Murmur 1/2/3 hashes\n\n## Downloads\n\nThe library can be downloaded from Maven Central using:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.sangupta\u003c/groupId\u003e\n    \u003cartifactId\u003emurmur\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Versioning\n\nFor transparency and insight into our release cycle, and for striving to maintain backward compatibility, \n`murmur` will be maintained under the Semantic Versioning guidelines as much as possible.\n\nReleases will be numbered with the follow format:\n\n`\u003cmajor\u003e.\u003cminor\u003e.\u003cpatch\u003e`\n\nAnd constructed with the following guidelines:\n\n* Breaking backward compatibility bumps the major\n* New additions without breaking backward compatibility bumps the minor\n* Bug fixes and misc changes bump the patch\n\nFor more information on SemVer, please visit http://semver.org/.\n\n## License\n\n```\nmurmur - Pure Java implementation of the Murmur Hash algorithms\nCopyright (c) 2014-2018, Sandeep Gupta\n\nThe project uses various other libraries that are subject to their\nown license terms. See the distribution libraries or the project\ndocumentation for more details.\n\nThe entire source is licensed under the Apache License, Version 2.0 \n(the \"License\"); you may not use this work except in compliance with\nthe LICENSE. You may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":["安全"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsangupta%2Fmurmur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsangupta%2Fmurmur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsangupta%2Fmurmur/lists"}