package main import ( "encoding/hex" "fmt" "testing" ) // buf.Write([]byte{0xFE, 0x5C, 0x4B, 0x89, 0x2A, 0x00, 0x00, 0x00}) // fmt.Println("buf", buf.Bytes()) // // fmt.Println("转换", hex.EncodeToString(buf.Bytes())) // // reply, _ := hex.DecodeString( // "fe5c4b892a000000") // fmt.Println("reply", reply) // encodeToGBK 将输入字符串编码为 GBK 字节切片 func Test_verify(t *testing.T) { //pack := protocol.InternalCodeDataPack{} // //contents := []promodel.InternalCodeContent{} // //c1 := promodel.InternalCodeContent{ // Text: "车牌:粤AB31Y9", // Color: 0x01, // Size: 0x11, //} //c2 := promodel.InternalCodeContent{ // Text: "金额:176.8元", // Color: 0x01, // Size: 0x11, //} //contents = append(contents, c1, c2) //code := pack.SendInternalCode(contents) //toString := hex.EncodeToString(code.Bytes()) //fmt.Println("======", toString) //rotate := protocol.Rotate([]byte{0x00, 0x06, 0x00, 0x17}) //fmt.Println("rotate", rotate) //远程喊话 //no := protocol.GetBytesArrNo(30, 2) //fmt.Println("no", no) //pack := protocol.VoiceBroadDataPack{} //broad := pack.VoiceBroad("欢迎光临") //fmt.Println("======", hex.EncodeToString(broad.Bytes())) inverse, _ := GetInverse(0x31) toString := hex.EncodeToString([]byte{inverse}) fmt.Println("====", toString) } func GetInverse(byteValue byte) (byte, error) { // 确保输入是 8 位字节 //if byteValue < 0 || byteValue > 255 { // return 0, errors.New("input must be an 8-bit byte (0-255)") //} // 计算反码 return ^byteValue, nil // 取反 }