Skip to content

大小端问题 #5

Description

@happyEgg

1、我将挑战码uint64类型转出[]byte,用的是大端转换的binary.Write(byteBuffer, binary.BigEndian, n)。。
func Int64ToByte(n uint64) []byte {
byteBuffer := bytes.NewBuffer([]byte{})
binary.Write(byteBuffer, binary.BigEndian, n)
return byteBuffer.Bytes()
}

func CheckMD5(num uint64) []byte {
h := md5.New()
h.Write(Int64ToByte(num))
h.Write([]byte("xxx"))

return h.Sum(nil)

}
2、而ServerID 却必须用小端转换才能读取正确。。

不能统一成大端或小端吗?
@idada

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions