java.lang.Object
com.pi4j.crowpi.components.internal.rfid.MifareKey

public final class MifareKey extends Object
Helper class for authenticating against MIFARE cards using either Key A or Key B. Provides getDefaultKeyA() and getDefaultKeyB() for retrieving the factory default keys (all FF).
  • Constructor Details

    • MifareKey

      public MifareKey(MifareKey.Type type, byte[] bytes)
      Creates a new MIFARE key which can be used for authenticating against a card.
      Parameters:
      type - Type of authentication key
      bytes - Contents of key, must be exactly 6 bytes
  • Method Details

    • getDefaultKeyA

      public static MifareKey getDefaultKeyA()
      Returns the default factory key (six times 0xFF) to be used as MifareKey.Type.KEY_A.
      Returns:
      Instance of default key A
    • getDefaultKeyB

      public static MifareKey getDefaultKeyB()
      Returns the default factory key (six times 0xFF) to be used as MifareKey.Type.KEY_B.
      Returns:
      Instance of default key B
    • getBytes

      public byte[] getBytes()
      Returns the raw content / bytes for this key.
      Returns:
      Byte array of key contents
    • getLength

      public int getLength()
      Returns the length of this key, should always be 6.
      Returns:
      Length of key
    • getType

      public MifareKey.Type getType()
      Returns the type of this key.
      Returns:
      Type of key