Golang encoding/hex.EncodeToString() function example
package encoding/hex
EncodeToString returns the hexadecimal encoding of src (1st parameter)
Golang encoding/hex.EncodeToString() function usage example
package main
import (
"encoding/hex"
"fmt"
)
func main() {
src := []byte("abcd")
str := hex.EncodeToString(src)
fmt.Printf("Encoded string in hexadecimal %v \n ", str)
}
Output :
Encoded string in hexadecimal 61626364
Reference :
Advertisement
Something interesting
Tutorials
+10.7k Golang : Get currencies exchange rates example
+13.1k Golang : How to get a user home directory path?
+26.8k Golang : Convert file content into array of bytes
+8.1k Golang : HTTP Server Example
+7.5k Golang : How to handle file size larger than available memory panic issue
+21.2k Golang : How to force compile or remove object files first before rebuild?
+52.6k Golang : How to get struct field and value by name
+22.2k Golang : Securing password with salt
+29.5k Golang : Login(Authenticate) with Facebook example
+14.3k Golang : How to shuffle elements in array or slice?
+19.4k Golang : How to count the number of repeated characters in a string?
+23.5k Golang : Get ASCII code from a key press(cross-platform) example