This repo contains a super basic app that demonstrates use of the Fingerprint API from Android Marshmallow (API 23). An AES encryption key is generated at app startup and stored in the Android KeyStore, and when a fingerprint is identified successfully the key is unlocked for a single use. If you attempt to use the key again, an exception will be thrown due to the user not being authenticated.
Note: This project uses Otto for passing events around. It's fairly straightforward, but see here for more info.
This class abstracts the following fingerprint-related functionality:
- Requesting the
USE_FINGERPRINTpermission (not needed currently, but it's there anyway) - Checking for hardware compatibility and enrolled fingerprints by way of
FingerprintManagerCompat - Scanning for fingerprints and cancelling a scan operation
- Handling
AuthenticationCallbackevents
CryptoHelper handles all cryptography logic, including:
- Generation of AES secret key and storage in the
KeyStore - Clearing a previously set key from the store
- Initialization of
Cipherwith the secret key - Encrypting a basic string of text
For extra information about this demo project and how to use the Fingerprint API, see this presentation.