mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 16:09:16 +02:00
fcl-hash: use randomize
This commit is contained in:
parent
6bf0de0ba2
commit
216c848075
@ -2,6 +2,7 @@ unit fpasn;
|
|||||||
|
|
||||||
{$mode ObjFPC}{$H+}
|
{$mode ObjFPC}{$H+}
|
||||||
{$modeswitch advancedrecords}
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
@ -19,10 +19,6 @@ unit fphashutils;
|
|||||||
{$mode ObjFPC}{$H+}
|
{$mode ObjFPC}{$H+}
|
||||||
{$modeswitch advancedrecords}
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
{$IF defined(CPUi386) or defined(CPUx86_64) }
|
|
||||||
{$define HasRDTSCP}
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -436,39 +432,20 @@ begin
|
|||||||
Result:=Copy(aSource,P1,P2-P1);
|
Result:=Copy(aSource,P1,P2-P1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF HasRDTSCP}
|
|
||||||
function RDTSCP: Int64; assembler; nostackframe;
|
|
||||||
asm
|
|
||||||
RDTSCP
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
function IntGetRandomNumber(aBytes : PByte; aCount: Integer): Boolean;
|
function IntGetRandomNumber(aBytes : PByte; aCount: Integer): Boolean;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
P : PByte;
|
P : PByte;
|
||||||
{$IFDEF HasRDTSCP}
|
|
||||||
{%H-}i64: int64;
|
|
||||||
j: integer;
|
|
||||||
{$ENDIF}
|
|
||||||
begin
|
begin
|
||||||
|
Randomize;
|
||||||
P:=aBytes;
|
P:=aBytes;
|
||||||
i:=0;
|
i:=0;
|
||||||
while i<aCount do
|
while i<aCount do
|
||||||
begin
|
begin
|
||||||
{$IFDEF HasRDTSCP}
|
|
||||||
i64:=RDTSCP;
|
|
||||||
j:=aCount-i;
|
|
||||||
if j>8 then j:=8;
|
|
||||||
system.move(i64,P^,j);
|
|
||||||
inc(p,j);
|
|
||||||
inc(i,j);
|
|
||||||
{$ELSE}
|
|
||||||
P^:=Random(256);
|
P^:=Random(256);
|
||||||
Inc(P);
|
Inc(P);
|
||||||
inc(i);
|
inc(i);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
Result:=True;
|
Result:=True;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user