# How can I use the Argon2 KDF in Processing?

**URL:** <https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420>\
**Category:** Libraries\
**Created:** [March 5, 2020, 2:44pm UTC](https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420 "2020-03-05T14:44:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon68884268](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon68884268](https://discourse.processing.org/u/anon68884268)\
**Post date:** [March 5, 2020, 2:44pm UTC](https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420/1 "2020-03-05T14:44:28Z")

</div>

Hello,  
I am trying to write a simple Messenger myself, and of course I can’t simply send the password of the user to the backend. I found [this GitHub repo](https://github.com/phxql/argon2-jvm), but I’m not quite sure how to use it. Cloning it with git and placing in the libaries folder inside the /Documents/Processing folder seems not to work. It’s structure is a completely other than the contributed libaries, but I found the Java source in Processing\libraries\argon2-jvm-master\src\main\java\de\mkammerer\argon2\ and a .jar file in Processing\libraries\argon2-jvm-master\gradle\wrapper. But when I try to compile with `java C:\Users\<username>\Documents\Processing\libraries\argon2-jvm-master\src\main\java\de\mkammerer\argon2\Argon2.java`, it says, “the main class could not be found”.

A bit additional background, i’m worrying about the security of my messenger.  
My OS: Windows 10  
Processing 3.5.4  
I have Java 8 myself installed

Thanks to everybody who tries to help me.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 6, 2020, 6:54pm UTC](https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420/2 "2020-03-06T18:54:43Z")

</div>

According to the Argon2 JVM repo that you linked it is sourceCompatibility = 1.6 – so it should work fine with Java8. Also, keep in mind that if you are using the Processing IDE (rather than Processing as a library, e.g. in Eclipse) then it uses its own internal Java 8, no matter what Java(s) you have installed on your system.

Are you writing a private messenger app using processing sketches as the messenger clients, e.g. for the desktop? And you want to log in to a server is using an Argon2 hash?

Here is a tutorial that might be helpful:

> **[How to Use Argon2 for Password Hashing in Java - Twelve 21](https://www.twelve21.io/how-to-use-argon2-for-password-hashing-in-java/)**
>
> Interested in utilizing the Argon2 password hashing algorithm in Java, but don't know how to get started? See how easy it is with argon2-jvm.

---

<div class="post-metadata">

**Author:** ![anon68884268](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon68884268](https://discourse.processing.org/u/anon68884268)\
**Post date:** [March 6, 2020, 8:50pm UTC](https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420/3 "2020-03-06T20:50:00Z")

</div>

First, thank you for your answer.  
Second, in the tutorial stands: `Let’s take a look at an example. First, add a dependency to your Maven’s pom.xml file to include argon2-jvm:`

```auto
<dependency>
    <groupId>de.mkammerer</groupId>
    <artifactId>argon2-jvm</artifactId>
    <version>2.5</version>
</dependency>

```

I heard Maven makes builds easier, but is Processing using it? Following, how can I add an dependency/include to my sketch? (Sorry if this all are idiotic questions, Processing is my first contact with Java)

Third, yes, I am writing an private messenger app with Processing, and I am writing the backend with Python’s Flask. For authentication I am using the HTTP Requests Library and Basic Authentication with POST Requests. I want to deveriate a key from the password of the user, and then send this key to the server, so he can search the user in his database and returns if he had success.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 6, 2020, 9:37pm UTC](https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420/4 "2020-03-06T21:37:12Z")

</div>

I haven’t tried using Maven with Processing – I was assuming that you would simply add the jar files you need to MySketchFolder/code/theArgonJAr.jar.

Anything in the code folder is in your sketch path, so you can `import` from it as per the tutorial. I don’t know about other dependencies.

---

<div class="post-metadata">

**Author:** ![anon68884268](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon68884268](https://discourse.processing.org/u/anon68884268)\
**Post date:** [March 7, 2020, 12:14pm UTC](https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420/5 "2020-03-07T12:14:19Z")

</div>

Hm, I am not sure if you mean the `gradle-wrapper.jar` in `argon2-jvm-master\gradle\wrapper`. Can I simply make a subdirectory named `code` and put the `gradle-wrapper.jar` in it? Then, should I then import it with

```java
import de.mkammerer.argon2.Argon2;

```

or

```java
import gradle-wrapper.argon2.Argon2;

```

?  
Should I copy the `gradle-wrapper.properties` alongside with it? Should I copy the whole directory alongside with it, or is everything included in `gradle-wrapper.jar`? (So many questions… thank you for your patience)

EDIT: Renaming it into `grwp.jar` and putting it into my `code` folder does not seem to work. Processing always cries,

```nohighlight
No library found for grwp
Libraries must be installed in a folder named 'libraries' inside the sketchbook folder (see the Preferences window).
The package “grwp” does not exist. You might be missing a library.

```

After closing Processing and putting the `grwp.jar` it into the `libraries` folder and reopening Processing, it shows in Sketch-\>Import Library `grwp`. But when I click on it, the following imports appear:

```java
import org.gradle.wrapper.*;
import org.gradle.cli.*;

```

which are not what I wanted. So where should I get the right .jar file?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 8, 2020, 4:47am UTC](https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420/6 "2020-03-08T04:47:05Z")

</div>

For the import statements in the tutorial, I think you might want

[https://jar-download.com/artifacts/de.mkammerer/argon2-jvm/2.6/source-code](https://jar-download.com/artifacts/de.mkammerer/argon2-jvm/2.6/source-code)

[Note: untested, I don’t know if this is a safe source, I just used it to peek at the jar contents]

but again, I know nothing about what dependencies if any might be missing – and if this client is a Java API to a system tool then you could need the non Java binary as well.

---

<div class="post-metadata">

**Author:** ![anon68884268](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon68884268](https://discourse.processing.org/u/anon68884268)\
**Post date:** [March 8, 2020, 3:31pm UTC](https://discourse.processing.org/t/how-can-i-use-the-argon2-kdf-in-processing/18420/7 "2020-03-08T15:31:56Z")

</div>

Got it!  
Indeed the link was the right `.jar` file, and it seems safe, I tested the file [here](https://www.virustotal.com/gui/file/8b351c2f66a67fe22ed79f3f5c32b1b17a5e57aab58d506caf8c63042c18ff3f/detection) and the site [here](https://www.virustotal.com/gui/url/3532f9be4d61850b31fd6800d3645f6811fc312f322b1f57d9413a859da68eb6/details). I put the `argon2-jvm-2.4.jar` in `Processing\processing-3.5.4\libraries\argon2lib\library\` and renamed it into `argon2lib.jar`. When I started Processing, in Sketch-\>Import Library appears `argon2lib`. When I click on it, the following appears in my sketch:  
 ![grafik](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6c483924039911ab0fe9b12f94015785368036eb.png)  
Success! Only one more thing: In the tutorial is used to create an Argon2Factory:

```auto
Argon2 argon2 = Argon2Factory.create(Argon2Types.ARGON2id);

```

But it cries again, “Argon2Type could not be found”. So I let it at

```auto
Argon2 argon2 = Argon2Factory.create();

```

. Thank you for your help.
