Foobar
This commit is contained in:
parent
19aa55d43e
commit
5e88923de4
|
@ -13,7 +13,7 @@
|
|||
{ Foundation, either version 3 of the License, or }
|
||||
{ (at your option) any later version. }
|
||||
{ }
|
||||
{ Foobar 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 }
|
||||
|
@ -40,6 +40,7 @@ Unit Renegade.Random.BSDRandom;
|
|||
interface
|
||||
|
||||
uses
|
||||
CTypes,
|
||||
Objects,
|
||||
Classes,
|
||||
SysUtils,
|
||||
|
@ -49,11 +50,16 @@ uses
|
|||
type
|
||||
PBSDRandom = ^BSDRandom;
|
||||
BSDRandom = class (RandomTrait, RandomInterface)
|
||||
private
|
||||
function GetSystemBytes(var RandomByteBuffer : TBytes; NBytes : SizeUint) : CInt;
|
||||
public
|
||||
function GetBytes(NBytes : SizeUInt) : TBytes;
|
||||
function GetString(NBytes : SizeUInt) : AnsiString;
|
||||
end;
|
||||
|
||||
procedure arc4random_buf(var Buffer : PCChar; StringLength : SizeInt);
|
||||
cdecl;varargs;external 'c' name 'arc4random_buf';
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{ Foundation, either version 3 of the License, or }
|
||||
{ (at your option) any later version. }
|
||||
{ }
|
||||
{ Foobar 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 }
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{ Foundation, either version 3 of the License, or }
|
||||
{ (at your option) any later version. }
|
||||
{ }
|
||||
{ Foobar 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 }
|
||||
|
|
|
@ -71,7 +71,6 @@ var
|
|||
RandomCharBuffer : PCChar;
|
||||
Return : CInt;
|
||||
begin
|
||||
Writeln(SYS_getrandom);
|
||||
GetMem(RandomCharBuffer, NBytes);
|
||||
Return := syscall(SYS_getrandom, @RandomCharBuffer^, NBytes, GRND_DEFAULT);
|
||||
Move(RandomCharBuffer[0], RandomByteBuffer[0], NBytes);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{ Foundation, either version 3 of the License, or }
|
||||
{ (at your option) any later version. }
|
||||
{ }
|
||||
{ Foobar 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 }
|
||||
|
|
|
@ -24,8 +24,6 @@ begin
|
|||
Assert(RRandom.InheritsFrom(RandomTrait));
|
||||
S := RRandom.GetString(22);
|
||||
T := RRandom.GetBytes(22);
|
||||
Writeln(S);
|
||||
Writeln(Length(S));
|
||||
Assert(Length(S) = 22);
|
||||
Assert(High(S) = 22);
|
||||
Assert(Low(S) = 1);
|
||||
|
|
Loading…
Reference in New Issue