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 (将#修改为@)