Asymmetric Encryption (Box)
Basic Usage
1. Generating Keys
// Alice and Bob generate their respective key pairs
val alice = Kodium.generateKeyPair()
val bob = Kodium.generateKeyPair()2. Encrypting a Message (Alice to Bob)
val message = "The eagle flies at midnight.".encodeToByteArray()
// Alice encrypts a message for Bob
val encryptedResult = Kodium.encryptToEncodedString(
mySecretKey = alice,
theirPublicKey = bob.getPublicKey(),
data = message
)
// The result is a Result<String> containing the Base58Check encoded ciphertext
val cipherTextString = encryptedResult.getOrThrow()3. Decrypting a Message (Bob from Alice)
Last updated