MariusBudin
MariusBudin

Reputation: 1287

Protect value with fingerprint

I’m implementing a “use fingerprint instead of password” feature for devices with nexus imprint.

It’s fairly easy to prompt for a fingerprint and see if was correct or not but I’m scratching my head trying to protect a value with fingerprint, I’m following this example https://github.com/googlesamples/android-FingerprintDialog but there is no “recover value with fingerprint”, it only explains how to store it

any good example of something like that?

The API expects a password so the general idea is:

Upvotes: 1

Views: 492

Answers (1)

MariusBudin
MariusBudin

Reputation: 1287

Okay, found the way, just for the record, here are the steps:

Init Cypher for decryption:

cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));

Create the CryptoObject with Cypher:

CryptoObject cryptoObject = new FingerprintManagerCompat.CryptoObject(cipher);
fingerprintManager.authenticate(cryptoObject, 0, cancellationSignal, callback, null);

Check the onAuthenticationSucceeded(AuthenticationResult) and get the value:

Cipher cipher = authenticationResult.getCryptoObject().getCipher();
byte[] encryptedBytes = cipher.doFinal("1234".getBytes("UTF-8"));

Upvotes: 2

Related Questions