Created
June 11, 2021 08:05
-
-
Save paralin/0af82b38e36da294b8d57ac2588bb862 to your computer and use it in GitHub Desktop.
go: generate 32 bytes and encode to hex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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