You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
372 B

package str
import "encoding/hex"
type Str struct {
}
// struing to hex
func (s *Str) HexEncode(str string) string {
byteStr := []byte(str)
return hex.EncodeToString(byteStr)
}
// hex to string
func (s *Str) HexDecode(str string) (string, error) {
hexStr, err := hex.DecodeString(str)
if err != nil {
panic(err)
return "", err
}
return string(hexStr), nil
}