aboutsummaryrefslogtreecommitdiff
path: root/src/stable/randomsystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/stable/randomsystem.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/stable/randomsystem.cpp b/src/stable/randomsystem.cpp
index 0501587..68c69d5 100644
--- a/src/stable/randomsystem.cpp
+++ b/src/stable/randomsystem.cpp
@@ -2,39 +2,39 @@
2#include "bu/file.h" 2#include "bu/file.h"
3 3
4Bu::RandomSystem::RandomSystem( Type eType ) : 4Bu::RandomSystem::RandomSystem( Type eType ) :
5 eType( eType ), 5 eType( eType ),
6 pSrc( 0 ) 6 pSrc( 0 )
7{ 7{
8 switch( eType ) 8 switch( eType )
9 { 9 {
10 case Bu::RandomSystem::Fast: 10 case Bu::RandomSystem::Fast:
11 pSrc = new Bu::File("/dev/urandom", Bu::File::Read ); 11 pSrc = new Bu::File("/dev/urandom", Bu::File::Read );
12 break; 12 break;
13 13
14 case Bu::RandomSystem::Good: 14 case Bu::RandomSystem::Good:
15 pSrc = new Bu::File("/dev/random", Bu::File::Read ); 15 pSrc = new Bu::File("/dev/random", Bu::File::Read );
16 break; 16 break;
17 } 17 }
18} 18}
19 19
20Bu::RandomSystem::~RandomSystem() 20Bu::RandomSystem::~RandomSystem()
21{ 21{
22 delete pSrc; 22 delete pSrc;
23} 23}
24 24
25void Bu::RandomSystem::seed( int32_t /*iSeed*/ ) 25void Bu::RandomSystem::seed( int32_t /*iSeed*/ )
26{ 26{
27 // Seed really has no effect here... 27 // Seed really has no effect here...
28 // on linux, if we were root, we could write data to random/urandom to 28 // on linux, if we were root, we could write data to random/urandom to
29 // perturb the data, but it's not necesarry 29 // perturb the data, but it's not necesarry
30} 30}
31 31
32int32_t Bu::RandomSystem::rand() 32int32_t Bu::RandomSystem::rand()
33{ 33{
34 if( !pSrc ) 34 if( !pSrc )
35 throw Bu::ExceptionBase("Not initialized"); 35 throw Bu::ExceptionBase("Not initialized");
36 int32_t i; 36 int32_t i;
37 pSrc->read( &i, sizeof(int32_t) ); 37 pSrc->read( &i, sizeof(int32_t) );
38 return i; 38 return i;
39} 39}
40 40