问题描述
如何制作使用移动指纹的移动应用程序&将指纹数据存储在sqlite数据库&比较...
我尝试过:
keyguardManager =
(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
fingerprintManager =
(FingerprintManager)getSystemService(FINGERPRINT_SERVICE);
protected void generateKey(){
try {
keyStore = KeyStore.getInstance(AndroidKeyStore);
} catch(异常e){
e.printStackTrace();
}
试试{
keyGenerator = KeyGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_AES,
AndroidKeyStore);
} catch(NoSuchAlgorithmException |
NoSuchProviderException e){
抛出新的RuntimeException(
无法获取KeyGenerator ins tance,e);
}
试试{
keyStore .load(null);
keyGenerator.init(新
KeyGenParameterSpec.Builder(KEY_NAME,
KeyProperties.PURPOSE_ENCRYPT |
KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
.setUserAuthenticationRequired(true)
.setEncryptionPaddings(
KeyProperties.ENCRYPTION_PADDING_PKCS7)
.build());
keyGenerator.generateKey();
} catch(NoSuchAlgorithmException |
InvalidAlgorithmParameterException
| CertificateException | IOException e){
抛出新的RuntimeException(e);
}
}
@TargetApi(Build.VERSION_CODES.M)
public boolean cipherInit(){
try {
cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES +/
+ KeyProperties.BLOCK_MODE_CBC +/
+ KeyProperties。 ENCRYPTION_PADDING_PKCS7);
} catch(NoSuchAlgorithmException |
NoSuchPaddingException e){
抛出新的RuntimeException(Failed to get Cipher,e);
}
尝试{
keyStore.load(null);
SecretKey key =(SecretKey)keyStore.getKey(KEY_NAME,
null);
cipher.init(Cipher.ENCRYPT_MODE,key);
返回true;
} catch(KeyPermanentlyInvalidatedException e){
返回false;
} catch(KeyStoreException | CertificateException
| UnrecoverableKeyException | IOException
| NoSuchAlgorithmException | InvalidKeyException e){
抛出新的RuntimeException(无法初始化密码,e);
}
}
how to make mobile apps that use mobile finger print & store finger print data on sqlite database & compare...
What I have tried:
keyguardManager =
(KeyguardManager) getSystemService(KEYGUARD_SERVICE);
fingerprintManager =
(FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
protected void generateKey() {
try {
keyStore = KeyStore.getInstance("AndroidKeyStore");
} catch (Exception e) {
e.printStackTrace();
}
try {
keyGenerator = KeyGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_AES,
"AndroidKeyStore");
} catch (NoSuchAlgorithmException |
NoSuchProviderException e) {
throw new RuntimeException(
"Failed to get KeyGenerator instance", e);
}
try {
keyStore.load(null);
keyGenerator.init(new
KeyGenParameterSpec.Builder(KEY_NAME,
KeyProperties.PURPOSE_ENCRYPT |
KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
.setUserAuthenticationRequired(true)
.setEncryptionPaddings(
KeyProperties.ENCRYPTION_PADDING_PKCS7)
.build());
keyGenerator.generateKey();
} catch (NoSuchAlgorithmException |
InvalidAlgorithmParameterException
| CertificateException | IOException e) {
throw new RuntimeException(e);
}
}
@TargetApi(Build.VERSION_CODES.M)
public boolean cipherInit() {
try {
cipher = Cipher.getInstance(
KeyProperties.KEY_ALGORITHM_AES + "/"
+ KeyProperties.BLOCK_MODE_CBC + "/"
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
} catch (NoSuchAlgorithmException |
NoSuchPaddingException e) {
throw new RuntimeException("Failed to get Cipher", e);
}
try {
keyStore.load(null);
SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME,
null);
cipher.init(Cipher.ENCRYPT_MODE, key);
return true;
} catch (KeyPermanentlyInvalidatedException e) {
return false;
} catch (KeyStoreException | CertificateException
| UnrecoverableKeyException | IOException
| NoSuchAlgorithmException | InvalidKeyException e) {
throw new RuntimeException("Failed to init Cipher", e);
}
}
推荐答案
这篇关于如何在自定义应用程序中使用移动指纹传感器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!