Interface Argon2

  • All Known Subinterfaces:
    Argon2Advanced

    public interface Argon2
    Argon2 password hashing function.

    All implementing classes need to be thread safe.

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.String hash​(int iterations, int memory, int parallelism, byte[] data)
      Hashes the given data.
      java.lang.String hash​(int iterations, int memory, int parallelism, char[] password)
      Hashes a password.
      java.lang.String hash​(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset)
      Hashes a password.
      java.lang.String hash​(int iterations, int memory, int parallelism, java.lang.String password)
      Deprecated.
      Use the hash(int, int, int, char[]) method instead.
      java.lang.String hash​(int iterations, int memory, int parallelism, java.lang.String password, java.nio.charset.Charset charset)
      Deprecated.
      Use the hash(int, int, int, char[], Charset) method instead.
      boolean needsRehash​(java.lang.String hash, int iterations, int memory, int parallelism)
      Checks if the given hash uses obsolete parameters like iterations, memory, parallelism.
      boolean verify​(java.lang.String hash, byte[] data)
      Verifies the given data against a hash.
      boolean verify​(java.lang.String hash, char[] password)
      Verifies a password against a hash.
      boolean verify​(java.lang.String hash, char[] password, java.nio.charset.Charset charset)
      Verifies a password against a hash.
      boolean verify​(java.lang.String hash, java.lang.String password)
      Deprecated.
      Use the verify(String, char[]) method instead.
      boolean verify​(java.lang.String hash, java.lang.String password, java.nio.charset.Charset charset)
      Deprecated.
      Use the verify(String, char[], Charset) method instead.
      void wipeArray​(byte[] array)
      Wipes the data from the given array.
      void wipeArray​(char[] array)
      Wipes the data from the given array.
    • Method Detail

      • hash

        @Deprecated
        java.lang.String hash​(int iterations,
                              int memory,
                              int parallelism,
                              java.lang.String password)
        Deprecated.
        Use the hash(int, int, int, char[]) method instead. Will be removed in version 3.
        Hashes a password.

        Uses UTF-8 encoding.

        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to hash
        Returns:
        Hashed password.
      • hash

        @Deprecated
        java.lang.String hash​(int iterations,
                              int memory,
                              int parallelism,
                              java.lang.String password,
                              java.nio.charset.Charset charset)
        Deprecated.
        Use the hash(int, int, int, char[], Charset) method instead. Will be removed in version 3.
        Hashes a password.
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to hash
        charset - Charset of the password
        Returns:
        Hashed password.
      • hash

        java.lang.String hash​(int iterations,
                              int memory,
                              int parallelism,
                              char[] password)
        Hashes a password.

        Uses UTF-8 encoding.

        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to hash
        Returns:
        Hashed password.
      • hash

        java.lang.String hash​(int iterations,
                              int memory,
                              int parallelism,
                              char[] password,
                              java.nio.charset.Charset charset)
        Hashes a password.
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to hash
        charset - Charset of the password
        Returns:
        Hashed password.
      • hash

        java.lang.String hash​(int iterations,
                              int memory,
                              int parallelism,
                              byte[] data)
        Hashes the given data.
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        data - Data to hash
        Returns:
        Hashed data.
      • verify

        @Deprecated
        boolean verify​(java.lang.String hash,
                       java.lang.String password)
        Deprecated.
        Use the verify(String, char[]) method instead. Will be removed in version 3.
        Verifies a password against a hash.

        Uses UTF-8 encoding.

        Parameters:
        hash - Hash.
        password - Password.
        Returns:
        True if the password matches the hash, false otherwise.
      • verify

        @Deprecated
        boolean verify​(java.lang.String hash,
                       java.lang.String password,
                       java.nio.charset.Charset charset)
        Deprecated.
        Use the verify(String, char[], Charset) method instead. Will be removed in version 3.
        Verifies a password against a hash.
        Parameters:
        hash - Hash.
        password - Password.
        charset - Charset of the password
        Returns:
        True if the password matches the hash, false otherwise.
      • verify

        boolean verify​(java.lang.String hash,
                       char[] password)
        Verifies a password against a hash.

        Uses UTF-8 encoding.

        Parameters:
        hash - Hash.
        password - Password.
        Returns:
        True if the password matches the hash, false otherwise.
      • verify

        boolean verify​(java.lang.String hash,
                       char[] password,
                       java.nio.charset.Charset charset)
        Verifies a password against a hash.
        Parameters:
        hash - Hash.
        password - Password.
        charset - Charset of the password
        Returns:
        True if the password matches the hash, false otherwise.
      • verify

        boolean verify​(java.lang.String hash,
                       byte[] data)
        Verifies the given data against a hash.
        Parameters:
        hash - Hash.
        data - Data.
        Returns:
        True if the data matches the hash, false otherwise.
      • wipeArray

        void wipeArray​(char[] array)
        Wipes the data from the given array.

        Use this method after hash creation / verification on the array which contains the user password.

        Parameters:
        array - The array to wipe.
      • wipeArray

        void wipeArray​(byte[] array)
        Wipes the data from the given array.

        Use this method after hash creation / verification on the array which contains the user password.

        Parameters:
        array - The array to wipe.
      • needsRehash

        boolean needsRehash​(java.lang.String hash,
                            int iterations,
                            int memory,
                            int parallelism)
        Checks if the given hash uses obsolete parameters like iterations, memory, parallelism.

        If one of the hash's parameters doesn't match the required minimum, this method will return true.

        Parameters:
        hash - a hash created by hash
        iterations - number of minimum iterations
        memory - minimum memory usage
        parallelism - minimum of parallelism
        Returns:
        true if the hash should be rehashed to match the given parameters, or false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if the hash is invalid