I am trying to convert a byte array to a hex string in mpcl. Here is the code from Sha256 HMAC. I saw a type defined as type stringSize string
but didn't get any tests on this.
In the code below I want to convert the variable key to a string and pass it to HMAC
hmac.SumSHA256([]byte("message"), []byte("abc"))
such that it looks like this:
hmac.SumSHA256([]byte("message"), []byte(string_key))
package main
import (
"crypto/hmac"
)
type Garbler struct {
msg [32]byte
keyShare [64]byte
}
func main(g Garbler, eKeyShare [64]byte) []byte {
var key [64]byte
for i := 0; i < len(key); i++ {
key[i] = g.keyShare[i] ^ eKeyShare[i]
}
import "fmt"
func main() {
byteArray := []byte{0x48, 0x65, 0x6C, 0x6C, 0x6F} // Example byte array
// Convert the byte array to a hexadecimal string
var hexString string
for _, b := range byteArray {
hexString += byteToHexString(b)
}
fmt.Println(hexString)
}
func byteToHexString(b byte) string {
hexChars := "0123456789ABCDEF"
high := b >> 4
low := b & 0x0F
return string(hexChars[high]) + string(hexChars[low])
}
but string is not accepted by mpcl. Can we write a package that handles this conversion?