Class Sector
Class representing a sector on a Mifare card
Defined in: mifare.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Sector(mifare, no)
Create an object representing an on card sector.
|
Method Attributes | Method Name and Description |
---|---|
authenticate(block, keytype)
Authenticate against block
Uses the internal key id for this sector for key A and the internal key id + 1 for key B. |
|
authenticatePublic(block, keytype)
Authenticate against block using list from public key table
|
|
getACforBlock(block)
Return access conditions for a block within the sector
|
|
read(block)
Read a block within the sector
|
|
readAll(keytype)
Read all blocks from a sector
|
|
setACforBlock(block, ac)
Set the access condition for a block within the sector
|
|
Set the data byte in the sector trailer
|
|
setKeyA(key)
Set the value for Key A
|
|
setKeyB(key)
Set the value for Key B
|
|
setKeyId(keyId, keytype)
Overwrite internal key id
|
|
<static> |
Sector.toASCII(data)
Convert binary data to ASCII code if within the range 0x20 to 0x7E
|
toString()
Return a human readable presentation of the sector
|
|
update(block, data)
Update a block within the sector
|
Class Detail
Sector(mifare, no)
Create an object representing an on card sector. Do not call directly but use Mifare.prototype.newSector() instead.
- Parameters:
- {Mifare} mifare
- the card
- {Number} no
- the sector number
Method Detail
{boolean}
authenticate(block, keytype)
Authenticate against block
Uses the internal key id for this sector for key A and the internal key id + 1 for key B.
- Parameters:
- {Number} block
- the block number between 0 and 3
- {Number} keytype
- must be either Mifare.KEY_A or Mifare.KEY_B
- Returns:
- true if authentication successfull
{Number}
authenticatePublic(block, keytype)
Authenticate against block using list from public key table
- Parameters:
- {Number} block
- the block number between 0 and 3
- {Number} keytype
- must be either Mifare.KEY_A or Mifare.KEY_B
- Returns:
- The key index in Mifare.PUBLICKEYS or -1 if not authenticated
{Number}
getACforBlock(block)
Return access conditions for a block within the sector
- Parameters:
- {Number} block
- the block number between 0 and 3
- Returns:
- one of the Sector.AC_ constants
{ByteString}
read(block)
Read a block within the sector
- Parameters:
- {Number} block
- the block number between 0 and 3
- Returns:
- the data read from the block
readAll(keytype)
Read all blocks from a sector
- Parameters:
- {Number} keytype
- key type to use for authentication (Mifare.KEY_A or Mifare.KEY_B. Defaults to key B.
setACforBlock(block, ac)
Set the access condition for a block within the sector
- Parameters:
- {Number} block
- the block number between 0 and 3
- {Number} ac
- one of the Sector.AC_ constants
setHeaderDataByte(db)
Set the data byte in the sector trailer
- Parameters:
- {ByteString} db
- the data byte (1 bytes)
setKeyA(key)
Set the value for Key A
- Parameters:
- {ByteString} key
- the key value (6 bytes)
setKeyB(key)
Set the value for Key B
- Parameters:
- {ByteString} key
- the key value (6 bytes)
setKeyId(keyId, keytype)
Overwrite internal key id
- Parameters:
- {Number} keyId
- the key id for the Mifare key
- {Number} keytype
- either Mifare.KEY_A (Default) or Mifare.KEY_B.
<static>
{String}
Sector.toASCII(data)
Convert binary data to ASCII code if within the range 0x20 to 0x7E
- Parameters:
- {ByteString} data
- the input data
- Returns:
- the ASCII string
toString()
Return a human readable presentation of the sector
update(block, data)
Update a block within the sector
- Parameters:
- {Number} block
- the block number between 0 and 3
- {ByteString} data
- the data to write (Optional for sector trailer)