Page 1 of 1

RNG question

Posted: 23 Oct 2018 17:19
by gduta
HxD is fantastic in the version 2.1 !!!! Thanks and congratulations!

One quick question. In the "Fill Selection" with "Random Bytes", what is the RNG method or API used by HxD ?

Re: RNG question

Posted: 24 Oct 2018 21:48
by Maƫl
It's from the Delphi runtime library:

Code: Select all

// Random integer, implemented as a deterministic linear congruential generator
// with 134775813 as a and 1 as c.
function Random(const ARange: Integer): Integer;
var
  Temp: Longint;
begin
  Temp := RandSeed * $08088405 + 1;
  RandSeed := Temp;
  Result := (UInt64(Cardinal(ARange)) * UInt64(Cardinal(Temp))) shr 32;
end;
RandSeed is initialized with time-like values:

Code: Select all

procedure Randomize;
var
  Counter: Int64;
begin
  if QueryPerformanceCounter(Counter) then
    RandSeed := Counter
  else
    RandSeed := GetTickCount;
end;

Re: RNG question

Posted: 25 Oct 2018 19:13
by gduta
Thanks!