Generate Given Number of Random Bytes using Go

math/rand package

package main

import (
    "fmt"
    "math/rand"
)

func main() {
    n := 8
    randomBytes := make([]byte, n)
    rand.Read(randomBytes)

    fmt.Println(randomBytes)
}

Leave a Comment

Cancel reply

Your email address will not be published.