Category: Kotlin

Kotlin doesn’t have a ternary operator

Every developer, one day or another, came across a situation where a variable should get a value or another based on a simple condition. In most programming languages you are able to write something like variable = (condition) ? <then> : <else>, in which if condition is true then variable takes the value of <then>, else it takes the value of <else>. Pretty straightforward.

In Kotlin, you can’t.

(more…)

Implementing RSA Cryptography in Kotlin

I needed to implement RSA-2048 cryptography into the Android application I’m currently writing. After a lot of trial and error, I’ve finally came up with a working solution, which I’m going to share here.

The application is a messaging service, so everything here will be applied to strings.
I’m going to split the code and remove some parts to make it easier to read and explain.

(more…)