StringToBytes() converts a hexadecimal string back into a byte slice
(s string)
| 541 | |
| 542 | // StringToBytes() converts a hexadecimal string back into a byte slice |
| 543 | func 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 |
| 556 | func BytesToTruncatedString(b []byte) string { |