Git Product home page Git Product logo

kotpass's Introduction

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

kotpass's People

Contributors

anvell avatar lukwol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kotpass's Issues

Coding suggestion for interop with JVM languages

Hi,

Thank you very much for this awesome library! It works really very well and serves very well one of my Android applications.

But I've noticed, that interop with Java is a little bit weird, because this library has extensions to the companion objects. For example function KeePassDatabase.Companion.decode, it will be compiled to something like this:

... KeePassDatabase decode(@NotNull KeePassDatabase.Companion $this$decode, ...)

In Java (or other JVM language) this metod requires instance of KeePassDatabase.Companion as an argument. Please consider avoiding it, if you care about interoperability.

Possibility to stream over a database?

Hi there.

Would it be possible to add a feature to stream over a database and return only the filtered entries by a supplied filter?
My problem are huge databases. We do have a DB which is round about 4gb in decoded state and it cannot be in ram the complete time.

Incompatibility with pykeepass

Started as this issue aivanovski/keepassvault#240, there are links to other issues inside, but I'm not sure if they provide some clarity.

It looks like there is some incompatibility with pykeepass library and after any field was inserted into database created by kotpass, kotpass interprets that fields as EntryValue.Encrypted. Before modification only password field was EntryValue.Encrypted.

Here are steps to reproduce:
1 - Create new database with kotpass (KeePassDatabase.Ver4x.create all default parameters), check that target field is EntryValue.Plain (use field notes, url, username)
2 - Modify target field with pykeepass
3 - Open database with kotpass, check the type of target field
Actuals result: target field is EntryValue.Encrypted
Expected result: target field is EntryValue.Plain

Python code for step 2:

from pykeepass import PyKeePass

kp = PyKeePass('test.kdbx', password='abc123')

entry = kp.root_group.entries[0]
entry.notes = "Notes from pykeepass"

kp.save()

And database file, password is abc123:
test.kdbx.zip

Crash during file decoding

Unfortunately I can't provide the database file itself as crash happens not on my device, but maybe it can be fixed.

kotpass version 0.6.0

Original issue

 java.lang.IndexOutOfBoundsException: Collection doesn't contain element at index 19.
    at kotlin.collections.CollectionsKt___CollectionsKt$elementAt$1.invoke(_Collections.kt:87)
    at kotlin.collections.CollectionsKt___CollectionsKt$elementAt$1.invoke(_Collections.kt:87)
    at kotlin.collections.CollectionsKt___CollectionsKt.elementAtOrElse(_Collections.kt:117)
    at kotlin.collections.CollectionsKt___CollectionsKt.elementAt(_Collections.kt:87)
    at app.keemobile.kotpass.xml.BinaryReferenceKt.unmarshalBinaryReference(BinaryReference.kt:22)
    at app.keemobile.kotpass.xml.EntryKt.unmarshalEntry(Entry.kt:64)
    at app.keemobile.kotpass.xml.GroupKt.unmarshalGroup(Group.kt:72)
    at app.keemobile.kotpass.xml.GroupKt.unmarshalGroup(Group.kt:69)
    at app.keemobile.kotpass.xml.GroupKt.unmarshalGroup(Group.kt:69)
    at app.keemobile.kotpass.xml.GroupKt.unmarshalGroup(Group.kt:69)
    at app.keemobile.kotpass.xml.DefaultXmlContentParser.unmarshalContent(DefaultXmlContentParser.kt:38)
    at app.keemobile.kotpass.database.DecoderKt.decode(Decoder.kt:96)
    at app.keemobile.kotpass.database.DecoderKt.decode$default(Decoder.kt:25)
    at com.ivanovsky.passnotes.data.repository.keepass.kotpass.KotpassDatabase$Companion.open(KotpassDatabase.kt:464)
    at com.ivanovsky.passnotes.data.repository.keepass.KeepassDatabaseRepository.openDatabase(KeepassDatabaseRepository.kt:196)
    at com.ivanovsky.passnotes.data.repository.keepass.KeepassDatabaseRepository.open(KeepassDatabaseRepository.kt:61)
    at com.ivanovsky.passnotes.domain.interactor.unlock.UnlockInteractor$openDatabase$2.invokeSuspend(UnlockInteractor.kt:111)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

Add to fdroid repo

Consider putting your app in an fdroid repository.

Either in izzy's repo or the fdroid official
Or create your own repository.

In advance a good app and good interface

Invalid entry field without id

Hallo,

when trying to unlock my kdbx file there is no access: Message "Invalid entry field without id".

Thanks.

KotpassDatabase$Companion(17) : app.keemobile.kotpass.errors.FormatError$InvalidXml: Invalid entry field without id. at app.keemobile.kotpass.xml.EntryKt.unmarshalField(Entry.kt:105) at app.keemobile.kotpass.xml.EntryKt.access$unmarshalField(Entry.kt:1) at app.keemobile.kotpass.xml.EntryKt.unmarshalEntry(Entry.kt:61) at app.keemobile.kotpass.xml.GroupKt.unmarshalGroup(Group.kt:78) at app.keemobile.kotpass.xml.DefaultXmlContentParser.unmarshalContent(DefaultXmlContentParser.kt:38) at app.keemobile.kotpass.database.DecoderKt.decode(Decoder.kt:96) at app.keemobile.kotpass.database.DecoderKt.decode$default(Decoder.kt:25) at com.ivanovsky.passnotes.data.repository.keepass.kotpass.KotpassDatabase$Companion.open(KotpassDatabase.kt:464) at com.ivanovsky.passnotes.data.repository.keepass.KeepassDatabaseRepository.openDatabase(KeepassDatabaseRepository.kt:196) at com.ivanovsky.passnotes.data.repository.keepass.KeepassDatabaseRepository.open(KeepassDatabaseRepository.kt:61) at com.ivanovsky.passnotes.domain.interactor.unlock.UnlockInteractor$openDatabase$2.invokeSuspend(UnlockInteractor.kt:111) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.