Skip to content
A Java implementation of the Libsodium crypto library. For the lazy dev.
Branch: master
Clone or download
gurpreet- ints to NativeLong
For better compatibility between 32 and 64 bit Android devices
Latest commit 4b168f3 Mar 7, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper Update version Mar 6, 2019
src ints to NativeLong Mar 7, 2019
.gitignore Added Auth functions May 8, 2018
Dockerfile Added initial files May 2, 2018
build.gradle ints to NativeLong Mar 7, 2019
gradlew.bat Added initial files May 2, 2018
settings.gradle Added Auth functions May 8, 2018

Lazysodium for Java

Lazysodium is a complete Java (JNA) wrapper over the Libsodium library that provides developers with a smooth and effortless cryptography experience.

Build Status Download

Why Lazysodium

We created Lazysodium because we really wanted a solid cryptography library that would just work without fuss.

We were exasperated and annoyed with current Libsodium implementations as some of them were just poorly maintained, poorly managed and, plain and simply, poorly architected. Lazysodium is made by DrLib (a part of Terl) that specialises in giving developers easy-to-use software and tools that just work.

You can find more info here.


You can find an up-to-date feature list here.

Quick start

Please view the official documentation for a more comprehensive guide.

1. Install

Install by adding the bintray repository and the dependency.

// Top level build file
repositories {
    maven {
        url  ""

// Add to dependencies section
dependencies {
    implementation "com.goterl.lazycode:lazysodium-java:VERSION_NUMBER"
    implementation ""

Substitute VERSION_NUMBER for the version in this box:


Substitute JNA_VERSION for the latest JNA version.

2. Let's go!

You can now initialise and start encrypting! Please note that this library follows the official libsodium docs closely. You need to use those docs to help you find the functions you need.

// Let's initialise LazySodium
LazySodiumJava lazySodium = new LazySodiumJava(new SodiumJava());

// Now you can cast to an interface so that our
// IDE picks up and intelligently loads up the correct methods. 
SecretBox.Native secretBoxNative = (SecretBox.Native) lazySodium;
SecretBox.Lazy secretBoxLazy = (SecretBox.Lazy) lazySodium;

// The first one is Lazysodium's Native implementation which
// is just like libsodium's native C function but with tiny enhancements
// to make your life easier.
// Convert key to string and save to DB

// This one is Lazysodium's Lazy implementation which makes
// your work with cryptography super easy.
Key key = secretBoxLazy.cryptoSecretBoxKeygen();

In the above code there are two ways you can use Lazysodium. The first way is through the Native interface. The second is through the Lazy interface.

3. You decide

Every project is different, you may need to use lower-level APIs to achieve the control you need so you use the Native interface. Or alternatively you just don't want to deal with the details so you stick to the Lazy interface.

Every interface you can cast to is helpfully all in one directory so you can easily pick the functions you need. This isolates your code and prevents you from making mistakes.

Important: If possible, please stick to using either the Native or the Lazy interface. The reason for this is that the Lazy interface normally converts everything to hexadecimal whereas the Native interface assumes everything is non-hexadecimal. If you don't know what you're doing, you could end up making mistakes.


See our official documentation to get started.


There are some example projects available here.

Lazysodium for Android

We also have an Android implementation available at Lazysodium for Android. It has the same API as this library so you can share code easily!

You can preview some of the features in our free Lazysodium app available on Google Play:

Get it on Google Play

Help us grow

Lazysodium needs your support for it to continue being maintained and improved. Even if you put forward £1/$1/€1 it still means a lot for us. Your money would go into improving our open-source projects first and foremost. If you want to find out more, use your preffered donation platform.

Patreon Terl Supporters
Currencies USD 100+ currencies

Patreon only has recurring subscriptions and rewards. Liberapay is another route you could take for subscription. We're also setting up our own system that allows one-off support amongst other things.

Who are we?

Created by the wizards at Terl.

You can’t perform that action at this time.