Imagine you are at a hotel where each lock to the rooms is controlled by Arduino with an NFC shield. When you arrive at your room and place the NFC card against the reader, Arduino will validate if it is indeed the correct card before releasing the lock.
In this recipe, we will create an Android application to write the room number on an NFC card encrypted with an AES algorithm.
We will encrypt the room door (padded left with 0
to have 16
as the length) with a 32-bit key and save the result to the tag:
Open Eclipse and create a new Android application project named
NfcBookCh9Example5
and package namednfcbook.ch9.example5
.Make sure the
AndroidManifest.xml
file is correctly configured. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.Add the following
string
to theres/values/strings.xml
file:<string name="dialog_waiting_tag">Waiting tag...</string> <string name="label_aes_key...