Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinorahto/709d0811492d42f3eb11cb677f0819d4 to your computer and use it in GitHub Desktop.
Save dinorahto/709d0811492d42f3eb11cb677f0819d4 to your computer and use it in GitHub Desktop.
val spec = KeyGenParameterSpec.Builder(
KEY_NAME,
KeyProperties.PURPOSE_ENCRYPT or
KeyProperties.PURPOSE_DECRYPT
).apply {
setBlockModes(KeyProperties.BLOCK_MODE_CBC)
setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
setUserAuthenticationRequired(true)
setUserAuthenticationValidityDurationSeconds(TIMEOUT_SECONDS)
setRandomizedEncryptionRequired(false)
}.build()
val masterKeyAlias = MasterKeys.getOrCreate(spec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment