Skip to content

Instantly share code, notes, and snippets.

zukopvd / Encryptor.kt
Created January 29, 2018 09:02
Android Encryptor (Helper class)
class Encryptor(private val sharedPreferences: SharedPreferences) {
private val ANDROID_KEY_STORE = "AndroidKeyStore"
private var initVector: ByteArray? = null
private var encryption: ByteArray? = null
private val TRANSFORMATION = "AES/GCM/NoPadding"
fun encryptTextWithAES(alias: String, textToEncrypt: String): ByteArray? {
var alias = alias
override fun onBindViewHolder(holder: ViewHolder,
position: Int,
payloads: MutableList<Any>) {
if (!payloads.isEmpty()) {
// Because these updates can be batched,
// there can be multiple payloads for a single bind
when (payloads[0]) {
// Change only the "favorite" icon,
// leave background image alone: