Interface Argon2Advanced

  • All Superinterfaces:
    Argon2

    public interface Argon2Advanced
    extends Argon2
    Advanced Argon2 hash functions.

    All implementing classes need to be thread safe.

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      byte[] generateSalt()
      Generates salt with the default length.
      byte[] generateSalt​(int lengthInBytes)
      Generates salt with the specified length in bytes.
      java.lang.String hash​(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt)
      Hashes a password, using the given salt.
      HashResult hashAdvanced​(int iterations, int memory, int parallelism, byte[] password, byte[] salt, int hashLength, Argon2Version version)
      Advanced version of hash, let the caller specify the hash length, the salt and the argon2 version.
      byte[] pbkdf​(int iterations, int memory, int parallelism, byte[] password, byte[] salt, int keyLength)
      Uses the given password to generate key material (password based key derivation).
      byte[] pbkdf​(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt, int keyLength)
      Uses the given password to generate key material (password based key derivation).
      byte[] rawHash​(int iterations, int memory, int parallelism, byte[] data, byte[] salt)
      Hashes the given data and returns the raw bytes.
      byte[] rawHash​(int iterations, int memory, int parallelism, char[] password, byte[] salt)
      Hashes a password and returns the raw bytes.
      byte[] rawHash​(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt)
      Hashes a password and returns the raw bytes.
      byte[] rawHash​(int iterations, int memory, int parallelism, java.lang.String password, byte[] salt)
      Deprecated.
      byte[] rawHash​(int iterations, int memory, int parallelism, java.lang.String password, java.nio.charset.Charset charset, byte[] salt)
      Deprecated.
      byte[] rawHashAdvanced​(int iterations, int memory, int parallelism, byte[] password, byte[] salt, byte[] secret, byte[] associatedData, int hashLength, Argon2Version version)
      Advanced version of hash, let the caller specify addition parameters such as hash length, salt, secret and associated data.
      byte[] rawHashAdvanced​(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt, byte[] secret, byte[] associatedData)
      Hashes a password, using the given salt, secret and associated data.
      boolean verifyAdvanced​(int iterations, int memory, int parallelism, byte[] password, byte[] salt, byte[] secret, byte[] associatedData, int hashLength, Argon2Version version, byte[] rawHash)
      Verifies a password against a hash.
      boolean verifyAdvanced​(int iterations, int memory, int parallelism, char[] password, java.nio.charset.Charset charset, byte[] salt, byte[] secret, byte[] associatedData, byte[] rawHash)
      Verifies a password against a hash.
    • Method Detail

      • rawHash

        @Deprecated
        byte[] rawHash​(int iterations,
                       int memory,
                       int parallelism,
                       java.lang.String password,
                       byte[] salt)
        Deprecated.
        Use the rawHash(int, int, int, char[], byte[]) method instead. Will be removed in version 3.
        Hashes a password and returns the raw bytes.

        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
        salt - Salt to use. This will override the default salt length
        Returns:
        Hashed password in raw bytes.
      • rawHash

        @Deprecated
        byte[] rawHash​(int iterations,
                       int memory,
                       int parallelism,
                       java.lang.String password,
                       java.nio.charset.Charset charset,
                       byte[] salt)
        Deprecated.
        Use the Argon2.hash(int, int, int, char[], Charset) method instead. Will be removed in version 3.
        Hashes a password and returns the raw bytes.
        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
        salt - Salt to use. This will override the default salt length
        Returns:
        Hashed password in raw bytes.
      • rawHash

        byte[] rawHash​(int iterations,
                       int memory,
                       int parallelism,
                       char[] password,
                       byte[] salt)
        Hashes a password and returns the raw bytes.

        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
        salt - Salt to use. This will override the default salt length
        Returns:
        Hashed password in raw bytes.
      • rawHash

        byte[] rawHash​(int iterations,
                       int memory,
                       int parallelism,
                       byte[] data,
                       byte[] salt)
        Hashes the given data and returns the raw bytes.
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        data - Data to hash
        salt - Salt to use. This will override the default salt length
        Returns:
        Hashed data in raw bytes.
      • rawHash

        byte[] rawHash​(int iterations,
                       int memory,
                       int parallelism,
                       char[] password,
                       java.nio.charset.Charset charset,
                       byte[] salt)
        Hashes a password and returns the raw bytes.
        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
        salt - Salt to use. This will override the default salt length
        Returns:
        Hashed password in raw bytes.
      • pbkdf

        byte[] pbkdf​(int iterations,
                     int memory,
                     int parallelism,
                     char[] password,
                     java.nio.charset.Charset charset,
                     byte[] salt,
                     int keyLength)
        Uses the given password to generate key material (password based key derivation).
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to generate key material from
        charset - Charset of the password
        salt - Salt to use. This will override the default salt length
        keyLength - Length of the returned key material in bytes.
        Returns:
        Key material.
      • pbkdf

        byte[] pbkdf​(int iterations,
                     int memory,
                     int parallelism,
                     byte[] password,
                     byte[] salt,
                     int keyLength)
        Uses the given password to generate key material (password based key derivation).
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to generate key material from
        salt - Salt to use. This will override the default salt length
        keyLength - Length of the returned key material in bytes.
        Returns:
        Key material.
      • hash

        java.lang.String hash​(int iterations,
                              int memory,
                              int parallelism,
                              char[] password,
                              java.nio.charset.Charset charset,
                              byte[] salt)
        Hashes a password, using the given salt.
        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
        salt - Salt
        Returns:
        Hashed password.
      • hashAdvanced

        HashResult hashAdvanced​(int iterations,
                                int memory,
                                int parallelism,
                                byte[] password,
                                byte[] salt,
                                int hashLength,
                                Argon2Version version)
        Advanced version of hash, let the caller specify the hash length, the salt and the argon2 version. Returns both the encoded and the raw hash.
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to hash
        salt - Salt to use. This will override the default salt length
        hashLength - Length of the returned hash in bytes.
        version - Argon2 version
        Returns:
        Hash result, containing both the raw and the encoded representation.
      • rawHashAdvanced

        byte[] rawHashAdvanced​(int iterations,
                               int memory,
                               int parallelism,
                               char[] password,
                               java.nio.charset.Charset charset,
                               byte[] salt,
                               byte[] secret,
                               byte[] associatedData)
        Hashes a password, using the given salt, secret and associated data.
        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
        salt - Salt
        secret - Secret (sometimes referred as Pepper)
        associatedData - Associated Data
        Returns:
        Hashed password in raw bytes.
      • rawHashAdvanced

        byte[] rawHashAdvanced​(int iterations,
                               int memory,
                               int parallelism,
                               byte[] password,
                               byte[] salt,
                               byte[] secret,
                               byte[] associatedData,
                               int hashLength,
                               Argon2Version version)
        Advanced version of hash, let the caller specify addition parameters such as hash length, salt, secret and associated data. Return both the encoded and the raw hash.
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to hash
        salt - Salt
        secret - Secret (sometimes referred as Pepper)
        associatedData - Associated Data
        hashLength - Length of the returned hash in bytes.
        version - Argon2 version
        Returns:
        Hashed password in raw bytes.
      • verifyAdvanced

        boolean verifyAdvanced​(int iterations,
                               int memory,
                               int parallelism,
                               char[] password,
                               java.nio.charset.Charset charset,
                               byte[] salt,
                               byte[] secret,
                               byte[] associatedData,
                               byte[] rawHash)
        Verifies a password against a hash.
        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
        salt - Salt
        secret - Secret (sometimes referred as Pepper)
        associatedData - Associated Data
        rawHash - Raw Hash bytes.
        Returns:
        True if the password matches the hash, false otherwise.
      • verifyAdvanced

        boolean verifyAdvanced​(int iterations,
                               int memory,
                               int parallelism,
                               byte[] password,
                               byte[] salt,
                               byte[] secret,
                               byte[] associatedData,
                               int hashLength,
                               Argon2Version version,
                               byte[] rawHash)
        Verifies a password against a hash.
        Parameters:
        iterations - Number of iterations
        memory - Sets memory usage to x kibibytes
        parallelism - Number of threads and compute lanes
        password - Password to hash
        salt - Salt
        secret - Secret (sometimes referred as Pepper)
        associatedData - Associated Data
        hashLength - Length of the returned hash in bytes.
        version - Argon2 version
        rawHash - Raw Hash bytes.
        Returns:
        True if the password matches the hash, false otherwise.
      • generateSalt

        byte[] generateSalt()
        Generates salt with the default length.
        Returns:
        Salt.
      • generateSalt

        byte[] generateSalt​(int lengthInBytes)
        Generates salt with the specified length in bytes.
        Parameters:
        lengthInBytes - Length of salt in bytes.
        Returns:
        Salt.