Skip to content

keemobile/kotpass

Repository files navigation

Kotpass

Build & Test 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

Kotpass is published on jitpack.io. Add repository it to your build.gradle script:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

and:

dependencies {
    implementation 'com.github.keemobile:kotpass:0.7.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!")
    }