RandToken genererates (with crypto/rand.Read) and returns a token that is the hex version (2x size) of size bytes of randomness.
(size int)
| 482 | // RandToken genererates (with crypto/rand.Read) and returns a token |
| 483 | // that is the hex version (2x size) of size bytes of randomness. |
| 484 | func RandToken(size int) string { |
| 485 | buf := make([]byte, size) |
| 486 | if n, err := rand.Read(buf); err != nil || n != len(buf) { |
| 487 | panic("failed to get random: " + err.Error()) |
| 488 | } |
| 489 | return fmt.Sprintf("%x", buf) |
| 490 | } |
no test coverage detected