Class Key
java.lang.Object
com.codename1.security.Key
- Direct Known Subclasses:
PrivateKey, PublicKey, SecretKey
Common base for every key type in the security package -- SecretKey for
symmetric algorithms, PublicKey and PrivateKey for asymmetric ones.
Holds the three pieces of metadata every key carries:
- an algorithm name (e.g. "AES", "RSA", "EC")
- a defensive copy of the encoded key bytes
- a format identifier (e.g. "RAW" for symmetric keys, "X.509" for SPKI public keys, "PKCS#8" for private keys)
Application code should not extend this class directly; create the concrete subtype that matches the algorithm you are using.
-
Constructor Details
-
Key
-
-
Method Details
-
getEncoded
public final byte[] getEncoded()Returns a fresh copy of the encoded key bytes. Treat returns from private keys as sensitive material -- do not log or store unencrypted. -
getAlgorithm
Returns the algorithm this key is intended for (e.g. "AES", "RSA"). -
getFormat
Returns the encoding format identifier. Standard values:
- "RAW" -- symmetric keys (
SecretKey) - "X.509" -- SubjectPublicKeyInfo DER (
PublicKey) - "PKCS#8" -- PrivateKeyInfo DER (
PrivateKey)
- "RAW" -- symmetric keys (
-