Awesome Open Source
Awesome Open Source

Argon2 Binding for the JVM Build & test

This is a JVM binding for Argon2.


With pre-compiled Argon2 libraries:


Without pre-compiled Argon2 libraries:



With pre-compiled Argon2 libraries:

compile 'de.mkammerer:argon2-jvm:2.7'

Without pre-compiled Argon2 libraries:

compile 'de.mkammerer:argon2-jvm-nolibs:2.7'


This binding needs the Argon2 C library. Libraries for the following operation systems are included in argon2-jvm library:

  • Linux x86
  • Linux x86-64
  • Linux ARM
  • Linux ARM-64
  • Windows x86
  • Windows x86-64
  • Darwin (OSX)

See tested distributions for details on which distributions this has been tested.

If you'd prefer to install/compile argon2 on your own you can use argon2-jvm-nolibs instead of argon2-jvm.

If you need help to build argon2, have a look at this documentation.

// Create instance
Argon2 argon2 = Argon2Factory.create();

// Read password from user
char[] password = readPasswordFromUser();

try {
    // Hash password
    String hash = argon2.hash(10, 65536, 1, password);

    // Verify password
    if (argon2.verify(hash, password)) {
        // Hash matches password
    } else {
        // Hash doesn't match password
} finally {
    // Wipe confidential data

Recommended parameters

The recommended parameters for the hash call above can be found in the whitepaper, section 9.

You can use the method Argon2Helper.findIterations to find the optimal number of iterations on your system:

Argon2 argon2 = Argon2Factory.create();
// 1000 = The hash call must take at most 1000 ms
// 65536 = Memory cost
// 1 = parallelism
int iterations = Argon2Helper.findIterations(argon2, 1000, 65536, 1);

System.out.println("Optimal number of iterations: " + iterations);

Technical details

This library uses JNA to communicate with the Argon2 C library.

Building it yourself

Run ./gradlew clean build to build and test the software.


Licensed under LGPL v3.


Moritz Kammerer (@phXql)


See contributing guidelines.


See contributors page.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
java (29,660
jvm (183
password (136
hashing (51
argon2 (17

Find Open Source By Browsing 7,000 Topics Across 59 Categories