We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In some devices the init Cipher doesn't work you need change your code to:
Kotlin code:
private fun initCipher() : Boolean { try { cipher = Cipher.getInstance( KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7 ) } catch (e:NoSuchAlgorithmException) { throw RuntimeException("Failed to get Cipher", e) } catch (e: NoSuchPaddingException) { throw RuntimeException("Failed to get Cipher", e) } return try { keyStore?.load(null) sharedPreferences.getString("biometric_param", null)?.let { val key = keyStore?.getKey(KEY_NAME, null) as SecretKey if (it.isNotEmpty()) { val arraysBytes = Base64.decode(it, Base64.NO_WRAP) val ivParams = IvParameterSpec(arraysBytes) cipher?.init(mode, key, ivParams) } } ?: run { cipher?.init(Cipher.ENCRYPT_MODE, generateKey()) val ivParams = cipher?.parameters?.getParameterSpec(IvParameterSpec::class.java) ivParams?.iv?.let { iv -> sharedPreferences.edit().apply { putString(BIOMETRIC_PARAM, Base64.encodeToString(iv, Base64.NO_WRAP)) } } } true } catch (e: KeyPermanentlyInvalidatedException) { false } catch (e: Exception) { throw java.lang.RuntimeException("Failed to init Cipher", e) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In some devices the init Cipher doesn't work you need change your code to:
Kotlin code:
The text was updated successfully, but these errors were encountered: