-
-
Save EMCP/d307a801da0462141a3e7662a720406a 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 = generateSecretKey() | |
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