Answer the question
In order to leave comments, you need to log in
Are cryptographically safe numbers in .NET faster than System.Random()?
Please explain why (at least in tests on PascalABC.NET) code #1 is ~3 times faster than code #2?
//№1
var
arr: array of byte;
rndg := new System.Security.Cryptography.RNGCryptoServiceProvider();
begin
setlength(arr, 10000000);
rndg.GetBytes(arr);
write(milliseconds());//от 50 до 70
end.
//№2
var
arr: array of byte;
rnd := new System.Random();
begin
setlength(arr, 10000000);
rnd.NextBytes(arr);
write(milliseconds);//от 160 до 200
end.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question