mirror of
https://github.com/tursom/GoCollections.git
synced 2025-03-14 18:02:23 +08:00
16 lines
256 B
Go
16 lines
256 B
Go
package hex
|
|
|
|
import (
|
|
"encoding/hex"
|
|
|
|
"github.com/tursom/GoCollections/unsafe"
|
|
)
|
|
|
|
func EncodeToString[T any](arr []T) string {
|
|
return hex.EncodeToString(unsafe.AsBytes(arr))
|
|
}
|
|
|
|
func DecodeString(s string) ([]byte, error) {
|
|
return hex.DecodeString(s)
|
|
}
|