Skip to content

Usage of Password4j

David Bertoldi edited this page Feb 18, 2021 · 6 revisions

Password4j uses 3 verbs:

  • hash in order to hash a plain text password
  • check in order to check and hash against a plain text password
  • update in order to update an hash after it is checked.

A possible statement is

Hash hash = Password.hash(plaintTextPassword)
                    .addNewRandomSalt()
                    .addPepper(somePepper)
                    .withSCrypt();       

which hashes a plainTextPassword with scrypt prepending somePepper and adding a randomly generated salt.

Aside from indentation, this is just a one line of Java code!

For more information about Password4j statements, see here.

The Hash object

Password4j documentation

Clone this wiki locally