Example #1
0
File: db.go Project: ghedo/safely
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
}
Example #2
0
File: db.go Project: ghedo/safely
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
}