Files
dasy/protobuf/messageid.go
Dean Eigenmann c2e58f0124 remove/protobuf-parent (#10)
* started removing

* updates

* fix

* please pass

* remove import
2019-10-22 11:08:57 +02:00

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[:]
}