Skip to content

Commit

Permalink
Improve comment for CRC32
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt authored and Sean-Der committed Apr 5, 2024
1 parent 1be706c commit 8d2181d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,12 @@ func (p *packet) marshal(doChecksum bool) ([]byte, error) {
}

if doChecksum {
// Checksum is already in BigEndian
// Using LittleEndian.PutUint32 stops it from being flipped
// golang CRC32C uses reflected input and reflected output, the
// net result of this is to have the bytes flipped compared to
// the non reflected variant that the spec expects.
//
// Use LittleEndian.PutUint32 to avoid flipping the bytes in to
// the spec compliant checksum order
binary.LittleEndian.PutUint32(raw[8:], generatePacketChecksum(raw))
}

Expand Down

0 comments on commit 8d2181d

Please sign in to comment.