Beispiel #1
0
func main() {
	file, _ := os.Open("./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())
}
Beispiel #2
0
func pickCredentialMode(password string) (*gokeepasslib.DBCredentials, error) {
	switch {
	case usePassword && keyFile != "":
		return gokeepasslib.NewPasswordAndKeyCredentials(
			password, keyFile,
		)
	case usePassword:
		credentials := gokeepasslib.NewPasswordCredentials(
			password,
		)
		return credentials, nil
	case keyFile != "":
		return gokeepasslib.NewKeyCredentials(keyFile)
	default:
		return nil, fmt.Errorf("Key file or password has to be provided")
	}
}