MCPcopy
hub / github.com/canopy-network/canopy / StringToBytes

Function StringToBytes

lib/util.go:543–553  ·  view source on GitHub ↗

StringToBytes() converts a hexadecimal string back into a byte slice

(s string)

Source from the content-addressed store, hash-verified

541
542// StringToBytes() converts a hexadecimal string back into a byte slice
543func StringToBytes(s string) ([]byte, ErrorI) {
544 // decode the hex string into bytes
545 b, err := hex.DecodeString(s)
546 // if an error occurred during the decode
547 if err != nil {
548 // exit with error
549 return nil, ErrStringToBytes(err)
550 }
551 // exit with bytes
552 return b, nil
553}
554
555// BytesToTruncatedString() converts a byte slice to a truncated hexadecimal string
556func BytesToTruncatedString(b []byte) string {

Callers 15

sendBlockRequestsMethod · 0.92
IndexTxMethod · 0.92
GetDoubleSignersMethod · 0.92
GetDoubleSignersAsOfMethod · 0.92
validatePollHashFunction · 0.92
UnmarshalJSONMethod · 0.92
CheckReplayMethod · 0.92
NewEditOrderTxFunction · 0.92
NewDeleteOrderTxFunction · 0.92
argGetAddrFunction · 0.92
argGetAddrOrNicknameFunction · 0.92
OrderMethod · 0.92

Calls 1

ErrStringToBytesFunction · 0.85

Tested by 2