https://github.com/sfuhrm/saphir-hash
Cryptographic message digest algorithms as a Java library with standard JCA adapters
https://github.com/sfuhrm/saphir-hash
crypto crypto-library cryptography cryptography-library cryptohash digest hash hashing hashing-algorithms java library md5 messagedigest ripemd160 sha1 sha2 sha256 tiger
Last synced: 3 days ago
JSON representation
Cryptographic message digest algorithms as a Java library with standard JCA adapters
- Host: GitHub
- URL: https://github.com/sfuhrm/saphir-hash
- Owner: sfuhrm
- License: other
- Created: 2014-05-02T17:59:37.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2025-07-02T12:52:44.000Z (3 months ago)
- Last Synced: 2025-07-20T19:41:35.047Z (3 months ago)
- Topics: crypto, crypto-library, cryptography, cryptography-library, cryptohash, digest, hash, hashing, hashing-algorithms, java, library, md5, messagedigest, ripemd160, sha1, sha2, sha256, tiger
- Language: Java
- Homepage:
- Size: 4.5 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Saphir Hash
===================[](https://github.com/sfuhrm/saphir-hash/actions/workflows/maven.yml)
[](https://github.com/sfuhrm/saphir-hash/actions/workflows/jacoco-badge.yml)
[](https://maven-badges.herokuapp.com/maven-central/de.sfuhrm/saphir-hash-core)
[](https://javadoc.io/doc/de.sfuhrm/saphir-hash-core)
[](https://opensource.org/licenses/MIT)Saphir Hash is a Java library for calculating cryptographic message digests.
The library is derived from the sphlib 3.0 code that can be found here:[http://www.saphir2.com/sphlib/](http://www.saphir2.com/sphlib/ "sphlib 3.0 project page")
The repackaged, mavenized and JCA-enabled version 3.0.3 and later can be found here:
[https://github.com/sfuhrm/saphir-hash](https://github.com/sfuhrm/saphir-hash "github saphir-hash project page")
Compared to the standard SUN message digest algorithm this library
contains many experimental hash algorithms.List of algorithms:
* BLAKE224,256,384,512
* BMW224,256,384,512
* CubeHash224,256,384,512
* ECHO224,256,384,512
* Fugue224,256,384,512
* Groestl224,256,384,512
* Hamsi224,256,384,512
* HAVAL128_3,128_4,128_5,160_3,160_4,160_5,192_3,192_4,192_5,224_3,224_4,224_5,256_3,256_4,256_5
JH224,256,384,512
* Keccak224,256,384,512
* Luffa224,256,384,512
* MD2
* MD4
* MD5
* PANAMA
* RadioGatun32,64
* RIPEMD128,160
* SHA0,1,224,256,384,512
* Shabal192,224,256,384,512
* SHAvite224,256,384,512
* SIMD224,256,384,512
* Skein224,256,384,512
* Tiger2
* Tiger
* Whirlpool0,1
* WhirlpoolDocumentation
----------------You can view the api docs online at [javadoc.io](https://javadoc.io/doc/de.sfuhrm/saphir-hash-core).
The documentation can be generated with the command```bash
mvn javadoc:aggregate
```Building
----------------The library is built with Apache Maven. You can build it by
doing```bash
mvn clean package
```in the top library folder.
Authors
----------------The original library was written by the "Projet RNRT SAPHIR",
which is a research project sponsored by the French government;
project members are public and private organizations:* Cryptolog
* ANSSI
* École Normale Superieure
* France Telecom
* GemaltoProjet RNRT SAPHIR was continued into Projet RNRT SAPHIR2, with four new additional members:
* Cassidian
* Morpho
* INRIA
* UVSQWe use the "Projet RNRT SAPHIR" expression to designate both SAPHIR and SAPHIR2.
All the actual code has been written by:
Thomas Pornin <thomas.pornin at cryptolog.com>
The additions were written by:
Stephan Fuhrmann <s at sfuhrm.de>
List of changes
----------------The following is a rough list of changes and additions done by me,
Stephan Fuhrmann:* Moved project structure to modern maven build with subprojects.
* Moved tests to JUnit tests.
* Created JCA adapter to the digest algorithms.
* Created speed benchmark code to compare against SUN and BouncyCastle implementations.Maven dependencies
----------------You can use the code using the Maven repository.
The core classes without JCA support is in this dependency (version may change):
```xml
de.sfuhrm
saphir-hash-core
3.0.10```
The JCA provider is contained in this dependency (version may change):
```xml
de.sfuhrm
saphir-hash-jca
3.0.10```
Example usage
----------------The following short example directly instantiates
fr.cryptohash.JCAProvider and calculates a digest over
the String "test" in the platforms default character encoding:```java
import fr.cryptohash.JCAProvider;
...MessageDigest mdSH = MessageDigest.getInstance("MD5", new JCAProvider());
mdSH.update("test".getBytes());
byte mdSHDigest[] = mdSH.digest();
```Performance discussion
----------------The following image shows the performance of different algorithm implementations
for a data size of 1M. The numbers are in nanoseconds:
The implementations are:
* JDK 1.8.0_121
* Bouncy Castle 1.46
* Saphir Hash JCA 3.0.3License
----------------The original library is in a MIT-like license, the rest is in a BSD-like license.
See the file LICENSE.md for a detailed discussion.