mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-01-18 18:31:56 +00:00
29 lines
462 B
Go
29 lines
462 B
Go
package statuskeycardgo
|
|
|
|
import "C"
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
)
|
|
|
|
func retValue(pairs ...interface{}) *C.char {
|
|
obj := make(map[string]interface{})
|
|
for i := 0; i < len(pairs)/2; i++ {
|
|
key := pairs[i*2]
|
|
value := pairs[(i*2)+1]
|
|
obj[key.(string)] = value
|
|
}
|
|
|
|
b, err := json.Marshal(obj)
|
|
if err != nil {
|
|
return C.CString(err.Error())
|
|
}
|
|
|
|
return C.CString(string(b))
|
|
}
|
|
|
|
func tox(bytes []byte) string {
|
|
return hex.EncodeToString(bytes)
|
|
}
|