mirror of https://bitbucket.org/ausocean/av.git
psi: using binary.BigEndian.PutUin32 to put crc32 into the psi
This commit is contained in:
parent
fa0154ad3d
commit
26f26cbeee
|
@ -27,6 +27,7 @@ LICENSE
|
||||||
package psi
|
package psi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/binary"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
)
|
)
|
||||||
|
@ -41,10 +42,7 @@ func addCrc(out []byte) []byte {
|
||||||
// updateCrc updates the crc of bytes slice, writing the checksum into the last four bytes.
|
// updateCrc updates the crc of bytes slice, writing the checksum into the last four bytes.
|
||||||
func updateCrc(b []byte) []byte {
|
func updateCrc(b []byte) []byte {
|
||||||
crc32 := crc32_Update(0xffffffff, crc32_MakeTable(bits.Reverse32(crc32.IEEE)), b[1:len(b)-4])
|
crc32 := crc32_Update(0xffffffff, crc32_MakeTable(bits.Reverse32(crc32.IEEE)), b[1:len(b)-4])
|
||||||
b[len(b)-4] = byte(crc32 >> 24)
|
binary.BigEndian.PutUint32(b[len(b)-4:], crc32)
|
||||||
b[len(b)-3] = byte(crc32 >> 16)
|
|
||||||
b[len(b)-2] = byte(crc32 >> 8)
|
|
||||||
b[len(b)-1] = byte(crc32)
|
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue