コード例 #1
0
ファイル: example.go プロジェクト: postfix/gokeepasslib
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())
}
コード例 #2
0
ファイル: helpers.go プロジェクト: tobischo/kp2
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")
	}
}