J
John Grandy
I'm not sure a full understanding of Guid creation would help my problem.
(Apparently, MAC IDs and a host of other system-specific characteristics are
used, and with enough randomly generated bits (Guid has 128), something
approaching randomness for any practical purpose is achieved.)
The (huge) problem I'm running into is how to "split bit boundaries of
randomness".
What am I talking about ?
Well, for example, if I require that my GUID string be built utilizing a set
of 52 chars (e.g. a-z A-Z), then I need 6 random bits to cover the target
range (e.g. 0-63 covers 0-51).
RNGCryptoServiceProvider.GetBytes() will generate me as many random bits as
I want.
However, on each occasion that 6 contiguous bits in the sequence represent a
value > 51 , it spells trouble. If I translate values > 51 back into the
required 0-51 range (e.g. via mod52), I effectively double the probability
of occurrence for each of 12 distinct values within that range (e.g. 0-11).
Any other translation scheme has the same problem.
It would seem that .NET's libs would provide some base functions that would
allow generation of cryptographically strong randomness within numeric
ranges that are not powers of 2.
Anyone know how to do this ?
(Apparently, MAC IDs and a host of other system-specific characteristics are
used, and with enough randomly generated bits (Guid has 128), something
approaching randomness for any practical purpose is achieved.)
The (huge) problem I'm running into is how to "split bit boundaries of
randomness".
What am I talking about ?
Well, for example, if I require that my GUID string be built utilizing a set
of 52 chars (e.g. a-z A-Z), then I need 6 random bits to cover the target
range (e.g. 0-63 covers 0-51).
RNGCryptoServiceProvider.GetBytes() will generate me as many random bits as
I want.
However, on each occasion that 6 contiguous bits in the sequence represent a
value > 51 , it spells trouble. If I translate values > 51 back into the
required 0-51 range (e.g. via mod52), I effectively double the probability
of occurrence for each of 12 distinct values within that range (e.g. 0-11).
Any other translation scheme has the same problem.
It would seem that .NET's libs would provide some base functions that would
allow generation of cryptographically strong randomness within numeric
ranges that are not powers of 2.
Anyone know how to do this ?