GenerateRandomID returns a cryptographically-secure 128-bit random number encoded as a hex string.
()
| 126 | |
| 127 | // GenerateRandomID returns a cryptographically-secure 128-bit random number encoded as a hex string. |
| 128 | func GenerateRandomID() (string, error) { |
| 129 | val, err := randCryptoHex(128) |
| 130 | if err != nil { |
| 131 | return "", fmt.Errorf("failed to generate random ID: %w", err) |
| 132 | } |
| 133 | return val, nil |
| 134 | } |
| 135 | |
| 136 | // randCryptoHex returns a cryptographically-secure random number of length sizeBits encoded as a hex string. |
| 137 | func randCryptoHex(sizeBits int) (string, error) { |