Skip to content
Switch branches/tags

Latest commit


Git stats


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

Lazysodium for Java

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

Checks Maven Central


This library is fully compatible with Kotlin.

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

Quick start

Please view the official documentation for a more comprehensive guide.

1. Install

Whatever build tool you're using the general gist is to add the mavenCentral() repository and then add the Lazysodium dependency. More detailed instructions here.

The following example is for users of the build tool Gradle:

// Top level build file
repositories {
    // Add this to the end of any existing repositories

// Project level dependencies section
dependencies {
    implementation "com.goterl:lazysodium-java:VERSION_NUMBER"
    implementation ""

Substitute VERSION_NUMBER for the version in this box:

Maven Central

Substitute JNA_NUMBER for the latest version of JNA.

2. Usage

You can now use the library. 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());

// Here's an example of hashing a password.
// Casting the lazySodium object is optional, 
// but it's wise to do so as it prevents accidents.
PwHash.Lazy pwHashLazy = (PwHash.Lazy) lazySodium;
String hash = pwHashLazy.cryptoPwHashStr("a cool password", PwHash.OPSLIMIT_MIN, PwHash.MEMLIMIT_MIN);

You can use the Native or Lazy interfaces to encrypt at a lower or a higher level. It's all very simple.

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.


Please view our official documentation to get started.


There are some example projects available here.

Used by

Name Short description
WordPress WordPress, one of the largest website builders, has Lazysodium powering their encryption in their Android app.
Dailymotion Kinta Dailymotion Kinta, end-to-end automation for mobiles
Threema (SaltyRTC) Threema is a global end-to-end encrypted chatting app and SaltyRTC is their protocol for encryption.
OpenHAB OpenHAB allows you to automate and superpower your home.
PayPay CardPaymentSDK is a card payments library to make payments through several payment methods painless. It uses PayPay as an endpoint to establish a payment security channel.
UXBOX UXBox, the open-source solution for design and prototyping
E3DB An encrypted NoSQL database designed from the ground-up for user privacy and security.
ADAMANT The most private messenger possible. Your device does not store any info. It directly interacts with the blockchain, where every byte is fully-encrypted.
Kepler A small TCP server written in Java powered by Netty, an asynchronous networking library.
Regen Ledger A global marketplace & contracting platform for Earth's ecosystem assets, services, and data.
Tezos The TezosJ SDK library enables plain Java developers to create applications that communicates with Tezos blockchain.
Exonum Exonum Java Binding is a framework for building blockchain applications in Java, powered by Exonum.
Paseto Java Implementation of Platform-Agnostic Security Tokens.
Recordo A super secure diary/journal that provides end to end encryption.

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

Created by Terl.