Skip to content

Instantly share code, notes, and snippets.

@lordcodes
Created February 16, 2020 21:35
Show Gist options
  • Save lordcodes/04dcc7975f1aa29b702d47cc1d58f050 to your computer and use it in GitHub Desktop.
Save lordcodes/04dcc7975f1aa29b702d47cc1d58f050 to your computer and use it in GitHub Desktop.
Code for the article: "Protecting secrets in an Android project"
fun encrypt(message: String): ByteArray {
val encryptionKey = generateKey()
val cell = SecureCell(encryptionKey, SecureCell.MODE_SEAL)
val protectedData = cell.protect(
encryptionContext, message.toByteArray()
)
return protectedData.protectedData
}
private val encryptionContext: ByteArray? = null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment