2021-01-06 09:35:05 +00:00
|
|
|
# Request utils.
|
|
|
|
|
2022-11-04 09:52:27 +00:00
|
|
|
when (NimMajor, NimMinor) < (1, 4):
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
else:
|
|
|
|
{.push raises: [].}
|
2021-07-22 08:43:41 +00:00
|
|
|
|
2022-09-07 15:31:27 +00:00
|
|
|
import bearssl/rand, stew/byteutils
|
2021-01-06 09:35:05 +00:00
|
|
|
|
2022-09-07 15:31:27 +00:00
|
|
|
proc generateRequestId*(rng: ref HmacDrbgContext): string =
|
2021-01-06 09:35:05 +00:00
|
|
|
var bytes: array[10, byte]
|
2022-09-07 15:31:27 +00:00
|
|
|
hmacDrbgGenerate(rng[], bytes)
|
2021-07-15 18:25:52 +00:00
|
|
|
return toHex(bytes)
|