Skip to content

The library offers reading and writing support for KeePass (KDBX) files in Kotlin

License

Notifications You must be signed in to change notification settings

keemobile/kotpass

Repository files navigation

Kotpass

Build & Test codecov badge

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.

See it in action

This library is used as backbone of KeeMobile password manager, check it out:

Get it on Google Play

Installation

The latest release is available on Maven Central.

dependencies {
    implementation("app.keemobile:kotpass:0.10.0")
}

Usage

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!")
    }