Include the argon2-jvm
dependency in your build.boot
or project.clj
file.
[de.mkammerer/argon2-jvm "2.5"]
In the module you need to use argon hashes, import the necessary classes in you namespace (ns
) declaration:
(:import
(de.mkammerer.argon2
Argon2Factory
Argon2Factory$Argon2Types))
Now you can generate a hash or verify if a string matches a hash like below:
(defonce ^:private ^:const arg2-iterations 8)
(defonce ^:private ^:const arg2-memory 65536)
(defonce ^:private ^:const arg2-parallelism 1)
(defn- argon2-hash
"Hash string with Argon2id"
[str-to-be-hashed]
(.hash argon2 arg2-iterations arg2-memory arg2-parallelism str-to-be-hashed))
(defn- argon2-verify
"verify argon2-hash(plaintext_str) == hashed_str"
[hashed-str plaintext-str]
(.verify argon2 hashed-str plaintext-str))
Adjust the arg2-iterations
, arg2-memory
and arg2-parallelism
as needed!