Skip to content
Libhydrogen implemented in Java.
Branch: master
Clone or download
Latest commit 8cb6c72 Aug 6, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea First commit Aug 4, 2019
gradle/wrapper Make LibraryLoader set correct permissions Aug 4, 2019
src Updated to be non-posix compatible Aug 6, 2019
.gitignore Make LibraryLoader set correct permissions Aug 4, 2019 First commit Aug 4, 2019 Readme platforms Aug 6, 2019
build.gradle Updated description Aug 6, 2019
gradlew First commit Aug 4, 2019
gradlew.bat First commit Aug 4, 2019
settings.gradle First commit Aug 4, 2019

Hydride (Java)

Hydride is a Java encryption library that allows developers to incorporate amazing cryptography that is compatible on a wide range of platforms into their projects. Hydride uses the Libhydrogen project via JNA wrapping.


Hydride is only available via Jitpack at the moment. Maven and SBT installation instructions available here.

// Top-level build.gradle
repositories {
    // ...
    maven { url '' } // Add this line

dependencies {
    // ...
    implementation 'com.github.libly:hydride-java:1.1.1' // Add this line

Supported platforms

Unlike other implementations, Hydride packages the shared libraries (, libhydrogen.dylib and libhydrogen.dll) within itself so you don't have to waste time compiling them. Other implementations probably force you to build those shared libraries or include a build step to build those shared libraries which, in my experience, fail most of the time. Platforms that are currently supported:

  • Windows 7 and above.
  • Ubuntu 14.04 and above*.
  • Android 16 and above.
  • iOS 10.2 and above.
  • MacOS 10.11 and above.
  • Armv6 and above (e.g. Raspberry Pi 2+, ODroid).

More platforms can be happily added, just create an issue.


To get started simple initialise an Hydrogen object and use its methods. Here's a simple example to get started:

// Initialise
Hydrogen hydrogen = new Hydrogen();

// Make a key
byte[] key = new byte[Hydrogen.HYDRO_SIGN_SECRETKEYBYTES];

// Make a cipher array to hold the resulting encrypted text
byte[] cipher = new byte[Hydrogen.HYDRO_SECRETBOX_HEADERBYTES + messageBytes.length];
String context = "context1";
byte[] contextBytes = context.getBytes();
String message = "This is a message that will be encrypted.";
byte[] messageBytes = message.getBytes();
long messageId = 1L;

// Now encrypt
int encryptSuccess = hydrogen.hydro_secretbox_encrypt(cipher, messageBytes, messageBytes.length, messageId, contextBytes, key);

For more information on how to use please refer to the Libhydrogen wiki where you can find a full list of all available operations. Just use hydrogen.your_operation_name() to use them.

You can’t perform that action at this time.