Use nimcrypto instead of sysrandom

The sysrandom package fails on 32 bit windows.
This commit is contained in:
Mark Spanbroek 2021-05-27 16:27:33 +02:00 committed by markspanbroek
parent 8fa017b492
commit f63c959f4d
2 changed files with 5 additions and 3 deletions

View File

@ -7,8 +7,8 @@ license = "MIT"
requires "nim >= 1.2.6"
requires "stew >= 0.1.0 & < 0.2.0"
requires "chronos >= 3.0.0 & < 4.0.0"
requires "nimcrypto >= 0.5.4 & < 0.6.0"
requires "ngtcp2 >= 0.32.0 & < 0.33.0"
requires "sysrandom >= 1.1.0 & < 2.0.0"
requires "upraises >= 0.1.0 & < 0.2.0"
requires "asynctest >= 0.2.1 & < 0.3.0"

View File

@ -1,6 +1,6 @@
import std/strutils
import std/hashes
import pkg/sysrandom
import pkg/nimcrypto
type ConnectionId* = distinct seq[byte]
@ -14,4 +14,6 @@ proc `$`*(id: ConnectionId): string =
"0x" & cast[string](id).toHex
proc randomConnectionId*(len = DefaultConnectionIdLength): ConnectionId =
ConnectionId(@(getRandomBytes(len)))
var bytes = newSeq[byte](len)
doAssert len == randomBytes(addr bytes[0], len)
ConnectionId(bytes)