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,731
  • 22
  • 33
  • 46
Reez0
  • 2,512
  • 2
  • 17
  • 39

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
  • 9,360
  • 2
  • 33
  • 47