Added GetSystemBytes for BSD Unit
This commit is contained in:
parent
5e88923de4
commit
d9678a6260
|
@ -57,11 +57,22 @@ type
|
||||||
function GetString(NBytes : SizeUInt) : AnsiString;
|
function GetString(NBytes : SizeUInt) : AnsiString;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure arc4random_buf(var Buffer : PCChar; StringLength : SizeInt);
|
procedure arc4random_buf(var Buffer : PCChar; StringLength : CInt);
|
||||||
cdecl;varargs;external 'c' name 'arc4random_buf';
|
cdecl;varargs;external 'c' name 'arc4random_buf';
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
function GetSystemBytes(var RandomByteBuffer : TBytes; NBytes : SizeUint) : CInt;
|
||||||
|
begin
|
||||||
|
arc4random_buf(@RandomByteBuffer^, NBytes);
|
||||||
|
if Length(RandomByteBuffer^) <> NBytes then
|
||||||
|
begin
|
||||||
|
Result := -1;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Result := Length(RandomByteBuffer^);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function BSDRandom.GetBytes(NBytes : SizeUInt) : TBytes;
|
function BSDRandom.GetBytes(NBytes : SizeUInt) : TBytes;
|
||||||
var
|
var
|
||||||
|
|
Loading…
Reference in New Issue