“codage hexagonal de Golang” Réponses codées

codage hexagonal de Golang

base641 := base64.NewEncoder(base64.StdEncoding, os.Stdout)
base641.Write([]byte("Hello world"))

decoded := base64.NewDecoder(base64.RawStdEncoding, strings.NewReader("SGVsbG8gd29y="))
hexRead, _ := ioutil.ReadAll(decoded)
fmt.Println(string(hexRead))
Restu Wahyu Saputra

codage hexagonal de Golang

package main

import (
    "fmt"
    "io/ioutil"
    "bytes"
    "encoding/hex"
    "log"
    "strings"
)

func main() {
	text := "Restu Wahyu Saputra"
	data := bytes.Buffer{} // buffer struct for get any output type from Writer if you want pass into terminal using type File

	encoded := hex.NewEncoder(&data)
	encoded.Write([]byte(text))

	fmt.Printf("Encoded data - %s \n", data.String())

	decoded := hex.NewDecoder(strings.NewReader(data.String()))
	read, err := ioutil.ReadAll(decoded) // this method for get any output from Reader

	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Decoded data - %s \n", string(read))
}
Restu Wahyu Saputra

Réponses similaires à “codage hexagonal de Golang”

Questions similaires à “codage hexagonal de Golang”

Plus de réponses similaires à “codage hexagonal de Golang” dans Go

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code