https://github.com/multiformats/java-multihash
A Java implementation of Multihash
https://github.com/multiformats/java-multihash
Last synced: about 1 year ago
JSON representation
A Java implementation of Multihash
- Host: GitHub
- URL: https://github.com/multiformats/java-multihash
- Owner: multiformats
- License: mit
- Created: 2016-10-09T15:58:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-03-01T13:41:56.000Z (over 1 year ago)
- Last Synced: 2025-03-31T13:17:04.036Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 425 KB
- Stars: 46
- Watchers: 11
- Forks: 30
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# java-multihash
[](http://ipn.io)
[](https://github.com/multiformats/multiformats)
[](https://webchat.freenode.net/?channels=%23ipfs)
[](https://travis-ci.org/multiformats/java-multihash)
[](https://jitpack.io/#multiformats/java-multihash)
[](https://github.com/RichardLitt/standard-readme)
> A Java implementation of [multihash](https://github.com/multiformats/multihash).
## Install
Simply clone this repository.
## Usage
```java
Multihash b58 = Multihash.decode("QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy");
Multihash b36 = Multihash.decode("kmue2y4illvr0m3lt8x6z8iwghtxlzdmkjh957p5rr5cdr9243ugc");
```
Note that this library only decodes & encodes Multihashes, and does not actually include any implementations of the hash functions themselves.
Consumers of this library can use different implementations for different reasons. Here are a few possible implementation choices for each `Multihash.Type`:
* [JDK's `MessageDigest`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/MessageDigest.html) supports (at least) these:
* md5 = MD5
* sha1 = SHA-1
* sha2-224 = SHA-224
* sha2-256 = SHA-256
* sha2-384 = SHA-384
* sha2-512 = SHA-512
* sha2-512-224 = SHA-512/224
* sha2-512-256 = SHA-512/256
* sha3_224 = SHA3-224
* sha3_256 = SHA3-256
* sha3_512 = SHA3-512
* [Google Guava's Hashing](https://github.com/google/guava/wiki/hashingexplained) offers [intentionally only](https://github.com/google/guava/issues/5990#issuecomment-2571350434) these:
* md5 = `@Deprecated Hashing.md5()`
* sha1 = `@Deprecated Hashing.sha1()`
* sha2_256 = `Hashing.sha256()`
* sha2_512 = `Hashing.sha512()`
* murmur3 = `Hashing.murmur3_32_fixed()`
* [Google Tink](https://developers.google.com/tink/supported-key-types#mac)
* AES-CMAC, see [Multicodec Issue #368](https://github.com/multiformats/multicodec/issues/368)
* [BouncyCastle](https://www.bouncycastle.org/documentation/specification_interoperability/)
* blake2*
* blake3*
* shake-*
* ripemd-*
* [Apache Commons Codec](https://commons.apache.org/proper/commons-codec/)
* blake3*
* murmur3
* [Jacksum](https://github.com/jonelo/jacksum)
* skein*
* ...
Please contribute an update to this list if you know of any other related libraries.
## Dependency
You can use this project by building the JAR file as specified below, or by using [JitPack](https://jitpack.io/#multiformats/java-multihash/) (also supporting Gradle, SBT, etc).
for Maven, you can add the follwing sections to your POM.XML:
```xml
jitpack.io
https://jitpack.io
com.github.multiformats
java-multihash
$LATEST_VERSION
```
## Testing
`mvn test`
## Building
`mvn package` will build a JAR file with Maven dependency information.
## Releasing
The version number is specified in the `pom.xml` file and must be changed in order to be accurately reflected in the JAR file manifest. A git tag must be added in the format "vx.x.x" for JitPack to work.
## Maintainers
Captain: [@ianopolous](https://github.com/ianopolous).
## Contribute
Contributions welcome. Please check out [the issues](https://github.com/multiformats/java-multihash/issues).
Check out our [contributing document](https://github.com/multiformats/multiformats/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
## License
[MIT](LICENSE) © 2015 Ian Preston