Skip to content

Instantly share code, notes, and snippets.

@paralin
Created June 11, 2021 08:05
Show Gist options
  • Select an option

  • Save paralin/0af82b38e36da294b8d57ac2588bb862 to your computer and use it in GitHub Desktop.

Select an option

Save paralin/0af82b38e36da294b8d57ac2588bb862 to your computer and use it in GitHub Desktop.
go: generate 32 bytes and encode to hex
package main
import (
"crypto/rand"
"encoding/hex"
"os"
)
func main() {
// generate 32 bytes key
d := make([]byte, 32)
_, err := rand.Read(d)
if err != nil {
panic(err)
}
os.Stdout.WriteString(hex.EncodeToString(d))
os.Stdout.WriteString("\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment