Skip to content

Most visited

Recently visited

navigation
Added in API level 1

PBEKeySpec

public class PBEKeySpec
extends Object implements KeySpec

java.lang.Object
   ↳ javax.crypto.spec.PBEKeySpec


The key specification for a password based encryption key.

Password based encryption is described in PKCS #5.

Summary

Public constructors

PBEKeySpec(char[] password)

Creates a new PBEKeySpec with the specified password.

PBEKeySpec(char[] password, byte[] salt, int iterationCount, int keyLength)

Creates a new PBEKeySpec with the specified password, salt, iteration count and the desired length of the derived key.

PBEKeySpec(char[] password, byte[] salt, int iterationCount)

Creates a new PBEKeySpec with the specified password, salt and iteration count.

Public methods

final void clearPassword()

Clears the password by overwriting it.

final int getIterationCount()

Returns the iteration count of this key specification.

final int getKeyLength()

Returns the desired key length of the derived key.

final char[] getPassword()

Returns a copy of the password of this key specification.

final byte[] getSalt()

Returns a copy of the salt of this key specification.

Inherited methods

From class java.lang.Object

Public constructors

PBEKeySpec

Added in API level 1
PBEKeySpec (char[] password)

Creates a new PBEKeySpec with the specified password.

Parameters
password char: the password.

PBEKeySpec

Added in API level 1
PBEKeySpec (char[] password, 
                byte[] salt, 
                int iterationCount, 
                int keyLength)

Creates a new PBEKeySpec with the specified password, salt, iteration count and the desired length of the derived key.

Parameters
password char: the password.
salt byte: the salt.
iterationCount int: the iteration count.
keyLength int: the desired key length of the derived key,
Throws
NullPointerException if the salt is null.
IllegalArgumentException if the salt is empty, iteration count is zero or negative or the key length is zero or negative.

PBEKeySpec

Added in API level 1
PBEKeySpec (char[] password, 
                byte[] salt, 
                int iterationCount)

Creates a new PBEKeySpec with the specified password, salt and iteration count.

Parameters
password char: the password.
salt byte: the salt.
iterationCount int: the iteration count.
Throws
NullPointerException if salt is null.
IllegalArgumentException if the salt is empty or iteration count is zero or negative.

Public methods

clearPassword

Added in API level 1
void clearPassword ()

Clears the password by overwriting it.

getIterationCount

Added in API level 1
int getIterationCount ()

Returns the iteration count of this key specification.

Returns
int the iteration count of this key specification.

getKeyLength

Added in API level 1
int getKeyLength ()

Returns the desired key length of the derived key.

Returns
int the desired key length of the derived key.

getPassword

Added in API level 1
char[] getPassword ()

Returns a copy of the password of this key specification.

Returns
char[] a copy of the password of this key specification.
Throws
IllegalStateException if the password has been cleared before.

getSalt

Added in API level 1
byte[] getSalt ()

Returns a copy of the salt of this key specification.

Returns
byte[] a copy of the salt of this key specification or null if none is specified.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.