Keys

Public Key

PublicKey publicKey(
    KeyStore keystore, 
    String alias
);

Loads a public key from a key store.

Usage Example

KeyStore keystore = keystore(
    "classpath:keystore.p12", 
    "password".toCharArray(), 
    "PKCS12"
);

PublicKey publicKey = publicKey(keystore, "alice");

Private Key

PrivateKey privateKey(
    KeyStore keystore, 
    String alias, 
    char[] password
);

Loads a public key from a key store. The password parameter is the private key's password.

Usage Example

Secret Key

Loads a secret key from a key store. The password parameter is the secret key's password.

Usage Example

Symmetric Key

Generates a symmetric key using the given algorithm.

Usage Example

Encoded Symmetric Key

Generates a symmetric key using the given algorithm and encoding.

Usage Example

Key Pair

Generates a pair of keys for asymmetric cryptography.

Usage Example

Key Pair with Custom PRNG

Same as key pair but allows passing a SecureRandom instance for custom initialization of the pseudo random number generator used when generating the keys.

Usage Example

Last updated

Was this helpful?