Generate random hex token using Go
How to generate a random hexadecimal token using Go
In my previous post we saw how to create random hex strings in various languages, and since I have started working with Go I found I needed a random hex token again. So like we saw in nodejs when you need to create unique token of some type, which you might use in a user email verification or password reset scenario, you can easily generate a random hex string like this
| |
The following is how you can generate the same kind of hexadecimal string in Go
| |
Please note you should not use the code above to generate any kind of password, or password related data in production. The code is meant only for random hex strings which can be used as short lived tokens.
This post is licensed under CC BY 4.0.