-
-
Save EMCP/5d4566aeac1468729101cbf852f7b1b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getSecretKey(sharedPref: SharedPreferences): SecretKey { | |
val key = sharedPref.getString(AppConstants.secretKeyPref, null) | |
if (key == null) { | |
//generate secure random | |
val secretKey = generateSecreKey() | |
saveSecretKey(sharedPref, secretKey!!) | |
return secretKey | |
} | |
val decodedKey = Base64.decode(key, Base64.NO_WRAP) | |
val originalKey = SecretKeySpec(decodedKey, 0, decodedKey.size, "AES") | |
return originalKey | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment