我正在使用 android Biometricx 库进行面部和指纹身份验证。当仅注册 FaceID 并且我尝试创建密钥时,我收到“ IllegalStatException:必须注册至少一个生物特征才能创建需要用户身份验证的密钥”
我正在尝试像这样创建secretKey
try {
mKeyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME,
KeyProperties.PURPOSE_ENCRYPT |
KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
// Require the user to authenticate with a fingerprint to authorize every use
// of the key
.setUserAuthenticationRequired(true)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
.build());
secretKey = mKeyGenerator.generateKey();
} catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException
| CertificateException | IOException e) {
Toast.makeText(this,"Create Key "+ e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
注册指纹时代码工作正常。这仅在注册 FaceId 时发生。我在这里想念什么?