如何解决CryptographyManager 使用的 secretKeyName 是什么?
我按照此指南 (https://developer.android.com/codelabs/biometric-login#2) 集成了生物识别身份验证。我有一个关于 secretKeyName 的问题。
private fun showBiometricPromptForEncryption() {
val canAuthenticate = BiometricManager.from(applicationContext).canAuthenticate()
if (canAuthenticate == BiometricManager.BIOMETRIC_SUCCESS) {
val secretKeyName = "biometric_sample_encryption_key"
cryptographyManager = CryptographyManager()
val cipher = cryptographyManager.getinitializedCipherForEncryption(secretKeyName)
val biometricPrompt =
BiometricPromptUtils.createBiometricPrompt(this,::encryptAndStoreServerToken)
val promptInfo = BiometricPromptUtils.createPromptInfo(this)
biometricPrompt.authenticate(promptInfo,BiometricPrompt.CryptoObject(cipher))
}
}
private fun showBiometricPromptForDecryption() {
ciphertextwrapper?.let { textwrapper ->
val secretKeyName = getString(R.string.secret_key_name)
val cipher = cryptographyManager.getinitializedCipherForDecryption(
secretKeyName,textwrapper.initializationVector
)
biometricPrompt =
BiometricPromptUtils.createBiometricPrompt(
this,::decryptServerTokenFromStorage
)
val promptInfo = BiometricPromptUtils.createPromptInfo(this)
biometricPrompt.authenticate(promptInfo,BiometricPrompt.CryptoObject(cipher))
}
}
我的问题是什么是secretKeyName
?加密提示中的 secretKeyName
是否与解密提示相同?我如何获得这个值?
谢谢!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。