如何在自定义应用程序中使用移动指纹传感器 [英] How to use mobile finger print sensor in custom app

查看:80
本文介绍了如何在自定义应用程序中使用移动指纹传感器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何制作使用移动指纹的移动应用程序&将指纹数据存储在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);
}
}

推荐答案

实际上你不能。指纹API不支持您要查找的内容。指纹数据由安卓系统存储在安全的地方,无法访问。

但您可以要求系统对用户进行身份验证。这是一个 github [ ^ ]来源。
Actually you can't. Fingerprint API doesn't support the things you are looking for. Fingerprint data are stored in a secure place by android system and are not accessible.
But you can ask the system to authenticate the user. Here's a github [^] source for you.


这篇关于如何在自定义应用程序中使用移动指纹传感器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆