This commit is contained in:
Zheng Kai
2023-03-30 16:41:44 +08:00
parent 049277f1f6
commit af429a393a
13 changed files with 155 additions and 29 deletions

22
server/src/pb/req.go Normal file
View File

@@ -0,0 +1,22 @@
package pb
import (
"crypto/md5"
"io"
)
// Hash ...
func (x *Req) Hash() [16]byte {
m := md5.New()
io.WriteString(m, x.Method)
m.Write([]byte{0x00})
io.WriteString(m, x.Method)
m.Write([]byte{0x00})
m.Write(x.Body)
var h [16]byte
copy(h[:], m.Sum(nil)[:])
return h
}