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.
    • 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.
      • 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.