RNG question

Help on how to use HxD.
Post Reply
gduta
Posts: 2
Joined: 23 Oct 2018 17:16

RNG question

Post 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 ?
Maël
Site Admin
Posts: 1454
Joined: 12 Mar 2005 14:15

Re: RNG question

Post 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;
gduta
Posts: 2
Joined: 23 Oct 2018 17:16

Re: RNG question

Post by gduta »

Thanks!
Post Reply