authenticate method
Authenticates a specified block with a provided key using standard security.
This method performs authentication on a specified block using a key of a predefined length. It is designed to work with RFID tags that support standard authentication mechanisms.
Parameters
blockNumber
: The block number to authenticate against.key
: A list of integers representing the key used for authentication. Must be exactly 6 bytes long.
Throws
Exception
if the key length is not 6 bytes, indicating an invalid key length.- Other exceptions may be thrown based on lower-level API errors or authentication failures.
Example
await reader.authenticate(blockNumber: 4, key: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]);
Note: The authentication mechanism and key management should adhere to the security requirements of the specific RFID system being interacted with.
Implementation
@override
Future<void> authenticate({
required int blockNumber,
required List<int> key,
}) async {
if (key.length != 6) {
throw Exception('Invalid key length');
}
const keyLocation = 0x00;
await _loadKey(
key: key,
keyLocation: keyLocation,
);
await _authenticate(
blockNumber: blockNumber,
keyType: AuthenticationKeyType.A,
keyLocation: keyLocation,
);
}