Search the Community
Showing results for tags 'random numbers'.
-
RdRand is Intel's on-chip hardware random number generator using entropy. This is just a quick response to this query; a faster solution would be to integrate some inline assembly (maybe using fasm?) The dll source is written by Stephen Higgins (blog here); there are several alternative codes available on GitHub as well. Usage for encryption is controversial (there are rumours of an NSA backdoor), but it may provide the closest approach to TRNG using PRNG. This is the 32-bit unsigned version, producing an integer in range: 0 to (4GB-1). Example: ; for dll source, see: https://github.com/viathefalcon/rdrand_msvc_2010 ; NB only some Intel CPUs support this feature $RdRandsupported=_RdRandInit() MsgBox(0,"Is RdRand supported on this CPU?",$RdRandsupported) if $RdRandsupported=False then Exit Global $lowerbound=0 ; NB: negative values are returned as 4GB - value (unsigned int) Global $upperbound=1000 ConsoleWrite("RdRand lower bound: " & $lowerbound & @CRLF) ConsoleWrite("RdRand upper bound: " & $upperbound & @CRLF & @CRLF) For $rc=1 To 100 ConsoleWrite("RdRand: " & @TAB & _RdRand($lowerbound, $upperbound) & @CRLF) Next _RdRandCleanUp() ;################################################################################## Func _RdRandInit() Global $DllHandleRdRand = DllOpen(".\RdRandlib.dll") If @error Then Return SetError(1,0,False) $result=DllCall($DllHandleRdRand, "bool", "rdrand_supported" ) If @error Then Return SetError(1,0,False) Return ($result[0]=1) EndFunc Func _RdRandCleanUp() If IsDeclared($DllHandleRdRand) Then DllClose($DllHandleRdRand) EndFunc Func _RdRand($lower, $upper) $result=DllCall($DllHandleRdRand, "uint", "rdrand_uniform_ex", "uint", $lower, "uint", $upper ) if @error then Return SetError(@error,@extended,False) Return $result[0] EndFunc RdRand.7z