Closed emartynov closed 3 years ago
Any thoughts people?
Sorry was caught up in some covid stuff.
Lazysodium definitely needs a Kotlin version. Android API 29 introduces a lot of nullability checks doesn't it? I think the recommended way is to use annotations.
1) I need to get this library up-to-date with API 29 using annotations (though this mixes Android with Java which is something I'm hesitant to do). 2) Get Kotlin working with Lazysodium.
Hi, I just tried using Lazysodium Java with Kotlin and all the methods return either a concrete non-nullable type or an exception. That is to say, the following works:
val lazySodium = LazySodiumAndroid(SodiumAndroid())
val message = "This is a super secret message."
val key = lazySodium.cryptoSecretBoxKeygen()
val nonce = lazySodium.nonce(SecretBox.NONCEBYTES)
val cipher = lazySodium.cryptoSecretBoxEasy(message, nonce, key)
val decrypted = lazySodium.cryptoSecretBoxOpenEasy(cipher, nonce, key)
Log.e("TESTAPP", decrypted) // Returns "This is a super secret message"
So by virtue of that, this is compatible with Android API 29+ and does not need extra work.
If you're still stuck, can you give me some sample problematic code?
Closing, cleaning up.
Hi people,
we are android devs and we use kotlin mostly. As for now we have code like this:
It returns default value if decrypt returns null. But I believe you don't return nulls and will throw exception. Also I see that a lot of methods are not accepting null params.
Could you annotate your function params and return values with Null aware annotations? If you follow non null defaults then you can do it for the whole package like described here https://stancalau.ro/java-package-nullability-contract/. This is supported by Kotlin compiler as well.