code: func (d *Decoder) Decode(db *Database) error {
  	// Read header
  	db.Header = new(DBHeader)
  	if err := db.Header.readFrom(d.r); err != nil {
  		return err
  	}
  
  	// Calculate transformed key to decrypt and calculate HMAC
  	transformedKey, err := db.getTransformedKey()
  	if err != nil {
  		return err
  	}
  
  	// Read hashes and validate them (Kdbx v4)
  	if db.Header.IsKdbx4() {
  		db.Hashes = new(DBHashes)
  		if err := db.Hashes.readFrom(d.r); err != nil {
  			return err
  		}
  
  		if db.Options.ValidateHashes {
  			if err := db.Header.ValidateSha256(db.Hashes.Sha256); err != nil {
  				return err
  			}
  
  			hmacKey := buildHmacKey(db, transformedKey)
  			if err := db.Header.ValidateHmacSha256(hmacKey, db.Hashes.Hmac); err != nil {
  				return errors.New("Wrong password? HMAC-SHA256 of header mismatching")
  			}
  		}
  	}
  
  	// Decode raw content
  	rawContent, _ := ioutil.ReadAll(d.r)
  	if err := decodeRawContent(db, rawContent, transformedKey); err != nil {
  		return err
  	}
  
  	contentReader := bytes.NewReader(db.Content.RawData)
  
  	// Read InnerHeader (Kdbx v4)
  	if db.Header.IsKdbx4() {
  		db.Content.InnerHeader = new(InnerHeader)
  		if err := db.Content.InnerHeader.readFrom(contentReader); err != nil {
  			return err
  		}
  	}
  
  	// Decode xml
  	xmlDecoder := xml.NewDecoder(contentReader)
  	return xmlDecoder.Decode(db.Content)
  }
docs: // Decode populates given database with the data of Decoder reader