Added GetSystemBytes for BSD Unit

This commit is contained in:
R. Eric Wheeler 2016-05-04 14:34:19 -07:00
parent 5e88923de4
commit d9678a6260
2 changed files with 13 additions and 2 deletions

View File

@ -57,11 +57,22 @@ type
function GetString(NBytes : SizeUInt) : AnsiString;
end;
procedure arc4random_buf(var Buffer : PCChar; StringLength : SizeInt);
procedure arc4random_buf(var Buffer : PCChar; StringLength : CInt);
cdecl;varargs;external 'c' name 'arc4random_buf';
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;
var

View File

@ -13,7 +13,7 @@
{ Foundation, either version 3 of the License, or }
{ (at your option) any later version. }
{ }
{ Renegade is distributed in the hope that it will be }
{ Renegade is distributed in the hope that it will be }
{ useful, but WITHOUT ANY WARRANTY; without even the }
{ implied warranty of MERCHANTABILITY or FITNESS FOR }
{ A PARTICULAR PURPOSE. See the GNU General Public }