Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

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.


repositories {
    maven {
        url  ""

dependencies {
    implementation "co.libly:hydride-java:1.1.3"

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.