RNG question

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

RNG question

Post by gduta » 23 Oct 2018 17:19

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: 1129
Joined: 12 Mar 2005 14:15

Re: RNG question

Post by Maël » 24 Oct 2018 21:48

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 » 25 Oct 2018 19:13

Thanks!

Post Reply