// Package mifare holds MIFARE Classic 1K layout helpers with no brand-specific memory map. package mifare import "fmt" const ( Sectors = 16 Blocks = 64 BlockSize = 16 SectorSize = 64 Size1K = 1024 ) // SectorOf returns the sector index for a block number (0–63). func SectorOf(block int) int { return block / 4 } // BlockRange returns the half-open block range [first, last) for a sector. func BlockRange(sector int) (first, last int) { first = sector * 4 last = first + 4 return first, last } // SectorBytes returns the 64-byte slice for sector (0–15) from a 1K image. func SectorBytes(image []byte, sector int) ([]byte, error) { if len(image) != Size1K { return nil, fmt.Errorf("image size: want %d got %d", Size1K, len(image)) } if sector < 0 || sector >= Sectors { return nil, fmt.Errorf("sector %d out of range", sector) } off := sector * SectorSize return image[off : off+SectorSize], nil }