hexstring

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2019 License: MIT Imports: 2 Imported by: 1

README

hexstring

Deal with strings of space separated hexadecimal bytes.

Example use

Convert a string with space separated numbers from 0x00 to 0xff to a byte slice:

helloWorldBytes, err := StringToBytes("48 65 6c 6c 6f 20 57 6f 72 6c 64 21")

General info

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(bs []byte) string

BytesToString converts a slice of bytes to a space sparated string of hexidecimal bytes (like "7f").

Example
helloWorldBytes, err := StringToBytes("48 65 6c 6c 6f 20 57 6f 72 6c 64 21")
if err != nil {
	panic(err)
}
fmt.Println(BytesToString(helloWorldBytes))
Output:

48 65 6c 6c 6f 20 57 6f 72 6c 64 21

func StringToBytes

func StringToBytes(hexstring string) ([]byte, error)

StringToBytes takes a space separated string of hexadecimal bytes (like "7f") and converts them to a slice of bytes.

Example
helloWorldBytes, err := StringToBytes("48 65 6c 6c 6f 20 57 6f 72 6c 64 21")
if err != nil {
	panic(err)
}
fmt.Println(helloWorldBytes)
Output:

[72 101 108 108 111 32 87 111 114 108 100 33]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL