Beispiel #1
0
func Dump(db_file string) ([]byte, error) {
	lock(db_file)
	defer unlock(db_file)

	plain, err := gpg.DecryptFile(db_file)
	if err != nil {
		return nil, fmt.Errorf("Could not decrypt DB: %s", err)
	}

	return plain, nil
}
Beispiel #2
0
func Open(db_file string) (*Db, error) {
	lock(db_file)
	defer unlock(db_file)

	plain, err := gpg.DecryptFile(db_file)
	if err != nil {
		return nil, fmt.Errorf("Could not decrypt DB: %s", err)
	}

	db := &Db{Path: db_file}

	err = json.Unmarshal(plain, db)
	if err != nil {
		return nil, fmt.Errorf("Could not decode DB: %s", err)
	}

	return db, nil
}