The library offers reading and writing support for KeePass (KDBX) files in Kotlin, including the latest format version 4.1. It is suitable for Mobile, Desktop, and Backend JVM projects. The functional style API makes it convenient for MVI-like architectures.
This library is used as backbone of KeeMobile password manager, check it out:
The latest release is available on Maven Central.
dependencies {
implementation("app.keemobile:kotpass:0.10.0")
}
Reading from file:
val credentials = Credentials.from(EncryptedValue.fromString("passphrase"))
val database = File("testfile.kdbx")
.inputStream()
.use { inputStream ->
KeePassDatabase.decode(inputStream, credentials)
}
KeePassDatabase
is represented as immutable object, in order to alter it use a set of modifier extensions.
Each time new KeePassDatabase
object is returned:
val groupUuid = UUID.fromString("c997344c-952b-e02b-06a6-29510ce71a12")
val newDatabase = database
.modifyMeta {
copy(generator = "Lorem ipsum")
}.modifyGroup(groupUuid) {
copy(name = "Hello kotpass!")
}