Class PasswordKeyDerivation


  • public class PasswordKeyDerivation
    extends Object
    Util class used for encryption key derivation from the password.
    • Method Detail

      • deriveKey

        public static byte[] deriveKey​(char[] password,
                                       byte[] salt,
                                       int iterations,
                                       int keySize)
        Derive key from the password with the usage of the salt.
        Uses algorithm PBKDF2WithHmacSHA256 for password derivation by default.
        Parameters:
        password - base for key derivation
        salt - salt for key derivation
        keySize - output key size in bits
        iterations - number of iterations used in derivation
        Returns:
        derived key from the password
      • deriveKey

        public static byte[] deriveKey​(String algorithm,
                                       String provider,
                                       char[] password,
                                       byte[] salt,
                                       int iterations,
                                       int keySize)
        Derive key from the password with the usage of the salt and selected algorithm.
        Parameters:
        algorithm - algorithm to be used for derivation
        provider - provider of the algorithm
        password - base for key derivation
        salt - salt for key derivation
        keySize - output key size in bits
        iterations - number of iterations used in derivation
        Returns:
        derived key from the password