mirror of
https://github.com/vacp2p/dasy.git
synced 2026-01-08 22:37:59 -05:00
16 lines
248 B
Go
16 lines
248 B
Go
package protobuf
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/binary"
|
|
)
|
|
|
|
func (m *Message) ID() []byte {
|
|
b := make([]byte, 4)
|
|
binary.LittleEndian.PutUint32(b, uint32(m.MessageType))
|
|
b = append(b, m.Body...)
|
|
|
|
hash := sha256.Sum256(b)
|
|
return hash[:]
|
|
}
|