mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
21 lines
317 B
Go
21 lines
317 B
Go
package utils
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"strings"
|
|
)
|
|
|
|
func SafeFirst16Bytes(data []byte) string {
|
|
if len(data) == 0 {
|
|
return "<empty>"
|
|
}
|
|
|
|
return strings.TrimPrefix(
|
|
strings.SplitN(hex.Dump(data), "\n", 2)[0],
|
|
"00000000 ",
|
|
)
|
|
}
|
|
|
|
func SafeFirst16Chars(s string) string {
|
|
return SafeFirst16Bytes([]byte(s))
|
|
}
|