Class SecretKey

java.lang.Object
com.codename1.security.Key
com.codename1.security.SecretKey

public final class SecretKey extends Key

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.

  • Constructor Details

    • SecretKey

      public SecretKey(String algorithm, byte[] keyBytes)

      Wraps existing key material.

      Parameters
      • algorithm: algorithm identifier (e.g. "AES")

      • keyBytes: raw key material -- defensively copied

  • Method Details

    • getBitLength

      public int getBitLength()
      Returns the length of the key in bits.