public final class SecretKey
A symmetric secret key. Used with Cipher (AES) and Hmac (via raw
bytes). For asymmetric algorithms use PublicKey / PrivateKey.
Keys carry the raw key material plus the algorithm name they are intended
for. They do not enforce length or strength – that is the caller’s
responsibility, although KeyGenerator will produce keys of standard
lengths.
Constructors
public SecretKey(String algorithm, byte[] keyBytes) | Wraps existing key material. |
Methods
public int getBitLength() | Returns the length of the key in bits. |
Inherited methods
From Key
Constructor details
SecretKey
public SecretKey(String algorithm, byte[] keyBytes)Wraps existing key material.
Parameters
algorithmString- algorithm identifier (e.g. “AES”)
keyBytesbyte[]- raw key material – defensively copied
Method details
getBitLength
public int getBitLength()Returns the length of the key in bits.