Class Dump

java.lang.Object
dev.hloth.zgztransport.Dump

public final class Dump extends Object
The blocks of a card, one after another, as MIFARE Classic Tool or a Proxmark writes them.

It hides the index arithmetic a raw byte array needs, so a caller can reach for one block without slicing:


 Dump dump = Dump.of(Files.readAllBytes(Path.of("dump.bin")));
 Transaction newest = Transaction.decode(dump.block(TransactionLog.LIVE_BLOCK));
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Fills the blocks of a dump one at a time, leaving the untouched ones zeroed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Bytes one block takes.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    block(int index)
    One block of this dump.
    int
    How many blocks this dump holds.
    builder(Chip chip)
    An empty dump of the size that chip has, to be filled block by block.
    byte[]
    The bytes of this dump.
    Reads the card this dump holds.
    boolean
    equals(Object other)
     
    int
     
    static Dump
    of(byte[] bytes)
    The dump those bytes hold.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Method Details

    • of

      public static Dump of(byte[] bytes)
      The dump those bytes hold.
      Parameters:
      bytes - whole blocks, which are copied
      Returns:
      the dump
      Throws:
      CardFormatException - if the length is not a multiple of the block size
    • builder

      public static Dump.Builder builder(Chip chip)
      An empty dump of the size that chip has, to be filled block by block.
      Parameters:
      chip - the chip whose layout the dump follows
      Returns:
      a builder over a dump of Chip.blocks() empty blocks
    • block

      public byte[] block(int index)
      One block of this dump.
      Parameters:
      index - the block number, counting from zero
      Returns:
      a copy of its sixteen bytes
      Throws:
      CardFormatException - if the dump stops before that block
    • blockCount

      public int blockCount()
      How many blocks this dump holds.
      Returns:
      the block count
    • bytes

      public byte[] bytes()
      The bytes of this dump.
      Returns:
      a copy of them
    • card

      public Card card()
      Reads the card this dump holds.
      Returns:
      the card
      Throws:
      CardFormatException - if the dump stops before the last block a card uses or a block does not decode
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object