ksprefs icon indicating copy to clipboard operation
ksprefs copied to clipboard

javax.crypto.IllegalBlockSizeException when pulling value consecutively

Open patzootz opened this issue 3 years ago • 1 comments

I'm using ksprefs library and from time to time i get javax.crypto.IllegalBlockSizeException I've found that if 2 threads or 2 calls are made at the same time the app crashes with the above exception. I can easily recreate the crash using these lines on samsung galaxy tab:

    for (i in 1..10){
        lifecycleScope.launch(Dispatchers.Default){
            val isEnabled = ZoeyApp.prefs.pull(booleanKey, true)
            Log.d("Testing", isEnabled.toString())
        }
    }

I have the prefs set us as such:

val prefs by lazy { KsPrefs(context) {
   encryptionType = EncryptionType.KeyStore("prefs")
}}

Thank you very much for the great lib!

patzootz avatar Oct 14 '21 07:10 patzootz

Sorry for the delay, will look into this as soon as I get the chance. Maybe there is some synchronization issue. I don't see a clear way out since the library is basically a wrapper for shared preferences.

cioccarellia avatar Jun 05 '22 21:06 cioccarellia

Better late than ever haha, just added multithreading support, pushing now

cioccarellia avatar Aug 31 '23 22:08 cioccarellia