A library to read and write keepass 2 files written in go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
crypto
examples
tests
wrappers
.gitignore
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
binary.go
binary_test.go
blocks.go
content.go
content_test.go
credentials.go
crypto.go
crypto_test.go
database.go
decoder.go
decoder_test.go
encoder.go
encoder_test.go
go.mod
go.sum
hashes.go
header.go
wrappers_test.go
xml.go

README.md

gokeepasslib

Travis Build state

gokeepasslib is a library which allows reading Keepass 2 files (kdbx).

Note: only Keepass v2.30 or higher is properly supported since earlier versions do not allow empty XML tags but expected self-closing tags (which is valid XML but not really supported by Golang on XML marshaling) Basically: this lib can probably read most Keepass2 files, but only Keepass v2.30 can be expected to read files created in this lib.

Installing

Use go get to retrieve the latest version:

go get -u github.com/tobischo/gokeepasslib

Include it in an application:

import "github.com/tobischo/gokeepasslib/v2"

Example: reading a file

package main

import (
    "fmt"
    "github.com/tobischo/gokeepasslib/v2"
    "os"
)

func main() {
    file, _ := os.Open("examples/example.kdbx")

    db := gokeepasslib.NewDatabase()
    db.Credentials = gokeepasslib.NewPasswordCredentials("abcdefg12345678")
    _ = gokeepasslib.NewDecoder(file).Decode(db)

    db.UnlockProtectedEntries()

    entry := db.Content.Root.Groups[0].Groups[0].Entries[0]
    fmt.Println(entry.GetTitle())
    fmt.Println(entry.GetPassword())
}

Note the db.UnlockProtectedEntries() call: you have to unlock protected entries before using the database and call db.LockProtectedEntries() before saving it to ensure that the passwords are not stored in plaintext in the xml. In kdbx files, which are encrypted using the file credentials, fields are protected with another stream cipher.

Example: writing a file

See examples/example-writing.go

TODO

  • Improve code readability
  • Write more tests

Changelog

CHANGELOG

License

LICENSE

Copyright

Copyright © 2018 Tobias Schoknecht. All rights reserved.