Search found 4233 matches

by deltarho[1859]
Feb 08, 2017 11:03
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

With regard different versions of Windows: Windows 95 and above: Can use CryptGenRandom Windows Vista and above: Can use BCryptGenRandom ( as posted ) As we progress from Windows 95, Microsoft stepped up and used the latest recommendation from the NIST with regard what the random number generator is...
by deltarho[1859]
Feb 08, 2017 10:08
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

Thanks, St_W. I am not up to speed with all the commands yet. :( CryptoRnd.bas is only a slight change to CryptoRndBufferCNG.inc but here it is. CryptoRnd.bas #include once "windows.bi" #include once "win/bcrypt.bi" #inclib "bcrypt" Dim Shared As Byte Ptr hRand Dim Shar...
by deltarho[1859]
Feb 07, 2017 23:10
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

Finally hit 1TB with a clean sweep except for the two unusual values during the 256MB run. I am glad about them - I think that I would find it a little disconcerting to get a clean sweep. The test went from 256MB, 512MB, ..., 1TB giving a total crunch of 2.38TB. I started another test and it wasn't ...
by deltarho[1859]
Feb 07, 2017 19:01
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

My_RNG was written in 'PowerBASC mode'. PowerBASIC has a command where an array and a string can share the same memory; without which I resorted to copying. The FreeBASIC docs make it clear that we should use StrPtr to point to a string's character data with VarPtr returning the address of the inter...
by deltarho[1859]
Feb 06, 2017 14:13
Forum: Sources, Examples, Tips and Tricks
Topic: On FreeBASIC's random number generators.
Replies: 35
Views: 9174

On FreeBASIC's random number generators.

I have been using PractRand for a few years now to examine the output of pseudo-random number generators. Unlike most compilers FreeBASIC offers a selection of generators so I subjected them to PractRand. PractRand is a very unforgiving suite of tests. Way back in 1995 George Marsaglia published Die...
by deltarho[1859]
Feb 05, 2017 14:22
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

I am having problems piping to PractRand ... I was using MKI without realising that what I actually needed was a MKUI, unsigned integer, and that doesn't exist. <laugh> So, what I am now doing is to populate a Ulong array with CryptoDW, copy the contents to a string and then stream the strings via ...
by deltarho[1859]
Feb 03, 2017 22:02
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

Tested to 64GB - only one anomaly at 512MB. I haven't seen that many tests do that well. If any random number generator never finds itself in the tail of a bell curve then we would have a contradiction. 128GB would take a further 140 minutes and doubling each time. A TB would take a further 35 hours...
by deltarho[1859]
Feb 03, 2017 19:27
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

I am having problems piping to PractRand so I dumped 256MB of CryptoDW ( 1GB ) to disk. 32MB, 64MB, 128MB, 256MB, 512MB and 1GB were tested. Four of them had no anomalies and two had one unusual value. Nothing wrong here - I have seen worse with Intel RdRand and quantum random number dumps. While I ...
by deltarho[1859]
Feb 03, 2017 15:49
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

Here is a typical run of the above:

Code: Select all

 0.5000036318678915
 0.5000035281555593
-9.399479785203934e-005
 6.767945995862125e-006
 127.49835567
by deltarho[1859]
Feb 03, 2017 15:33
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

I now have a library: http://deltarho.org.uk/Downloads/CryptoRnd.zip The download is a zipped folder which unzips to CryptoRnd where you will find CryptoRnd.bi and libCryptoRnd.a. The library is only 4612 bytes. I thought that using a library would slow things down a bit, but it hasn't. For the time...
by deltarho[1859]
Feb 03, 2017 13:18
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

multiply by a floating point constant Did some tests and averaged. 125MB of CryptoS took 493.309ms with the constant multiplier approach and 467.097ms with the code as published. I thought your constant multiplier may have an edge but I was wrong, although we only have a difference of 5%. Credit to...
by deltarho[1859]
Feb 03, 2017 6:56
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

Re: A fast CPRNG

or 2.328306436538696289063e-10 ( from 1/2^32 ) for 32 bit [0,1), but where is the fun in that? Anyway the main use of pseudo-random number generators in most applications is correlation breaking, which fortunately isn't too difficult. I was wondering what that has to do with the price of bacon but t...
by deltarho[1859]
Feb 03, 2017 0:29
Forum: Windows
Topic: A fast CPRNG
Replies: 85
Views: 22335

A fast CPRNG

We are spoilt for choice with regard random number generators. Algorithm 5 provides cryptographic random numbers. For Windows, the CryptoAPI is used via CryptGenRandom. A better quality generator is with 'Cryptography API: Next Generation' introduced in Windows Vista via BCryptGenRandom. Both genera...
by deltarho[1859]
Jan 24, 2017 18:21
Forum: Sources, Examples, Tips and Tricks
Topic: MacroTimersQPC.inc
Replies: 21
Views: 6846

Re: MacroTimersQPC.inc

A request for n-1 milliseconds would see a delay of, roughly, n-1 to n milliseconds. Occasionally, we overshoot n milliseconds so there is no need to poll QueryPerformanceCounter. We can test if an overshoot has occurred but this would incur a greater overshoot. A solution is to use Sleep( n-2,1 )....
by deltarho[1859]
Jan 22, 2017 22:40
Forum: Sources, Examples, Tips and Tricks
Topic: MacroTimersQPC.inc
Replies: 21
Views: 6846

Re: MacroTimersQPC.inc

Here is another macro to add to the above although it doesn't time an interval but creates one. A simple analogy of the method employed is to consider amplification in a Hi-Fi system. We could have a powerful Class B amplifier which doesn't sound too good but didn't cost much. On the other hand, we ...