0

Using python you could use the secrets module like this.

    import secrets
    print(secrets.token_hex(16))

    >>> a67c39a93429f53e5c2a711b0c8455b6

Is there a similar way to do this using Go?

pppery
  • 3,550
  • 19
  • 28
  • 41
Reez0
  • 2,112
  • 2
  • 19
  • 34

1 Answers1

0

Use the crypto/rand package, something like this:

b := make([]byte, length)
_, err := rand.Read(b)
if err != nil {
    fmt.Println("error reading random token:", err)
    return nil
}
Kenny Grant
  • 8,790
  • 2
  • 30
  • 45