hedgewars/uRandom.pas
changeset 22 517be8dc5b76
parent 21 dff476dcaaa3
child 102 c45643d3fd78
equal deleted inserted replaced
21:dff476dcaaa3 22:517be8dc5b76
    64 function  GetRandom(m: LongWord): LongWord;
    64 function  GetRandom(m: LongWord): LongWord;
    65 var dig: TSHA1Digest;
    65 var dig: TSHA1Digest;
    66 begin
    66 begin
    67 SHA1Update(sc1, @Fill[1], Length(Fill));
    67 SHA1Update(sc1, @Fill[1], Length(Fill));
    68 sc2:= sc1;
    68 sc2:= sc1;
    69 dig:= SHA1Final(sc1);
    69 dig:= SHA1Final(sc2);
    70 Result:= (dig.LongWords[0] + dig.LongWords[2] + dig.LongWords[3]) mod m;
    70 Result:= (dig.LongWords[0] + dig.LongWords[2] + dig.LongWords[3]) mod m
    71 sc1:= sc2
       
    72 end;
    71 end;
    73 
    72 
    74 end.
    73 end.