This repository is part of the example accompanying the following article:
Rust + KMP: System Performance Meets Multiplatform Delivery
kchacha20 is a Kotlin Multiplatform wrapper around a rust authenticated encryption implementation built on chacha20poly1305.
The cryptographic operations (key derivation and AEAD encryption/decryption) are executed in native Rust for performance and memory safety,
while Kotlin exposes a structured, AutoCloseable API to ensure effective cleanup of native resources.
Use this lib:
Add it to your dependencies:
io.github.shadmanadman:kchacha20lib:0.20.6
Call create on KChaCha20. give it a masterPassword and your salt. this will be used as your cipher password:
KChaCha20.use{
it.create(masterPassword,salt)
}
KChaCha20.close()
Encrypt your data:
KChaCha20.use{
it.encrypt(input: String):ByteArray
}
Decrypt the data:
KChaCha20.use{
it.decrypt(encryptedData: ByteArray):String
}