// GetContent returns a string which is the plaintext content of a binary
GetContent returns a string which is the plaintext content of a binary
// GetContent returns a string which is the plaintext content of a binary
func (b Binary) GetContent() (string, error) {
	decoded := make([]byte, base64.StdEncoding.DecodedLen(len(b.Content)))
	_, err := base64.StdEncoding.Decode(decoded, b.Content)
	if err != nil {
		decoded = b.Content[:]
	}
	if b.Compressed.Bool {
		reader, err := gzip.NewReader(bytes.NewReader(decoded))
		if err != nil {
			return "", err
		}
		defer reader.Close()
		bts, err := ioutil.ReadAll(reader)
		if err != nil && err != io.ErrUnexpectedEOF {
			return "", err
		}
		return string(bts), nil
	}
	return string(decoded), nil
}
func ( b Binary ) GetContent ( ) ( string , error ) { decoded := make ( [ ] byte , base64 . StdEncoding . DecodedLen ( len ( b . Content ) ) ) _ , err := base64 . StdEncoding . Decode ( decoded , b . Content ) if err != nil { decoded = b . Content [ : ] } if b . Compressed . Bool { reader , err := gzip . NewReader ( bytes . NewReader ( decoded ) ) if err != nil { return " " , err } defer reader . Close ( ) bts , err := ioutil . ReadAll ( reader ) if err != nil && err != io . ErrUnexpectedEOF { return " " , err } return string ( bts ) , nil } return string ( decoded ) , nil }
GetContent returns a string which is the plaintext content of a binary
GetContent returns a string which is the plaintext content of a binary
// Check for base64 content (KDBX 3.1), if it fail try with KDBX 4 // KDBX 4 doesn't encode it