irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_random.cpp
Go to the documentation of this file.
1 #include <boost/random.hpp>
2 #include <openssl/rand.h>
3 #include "irods_random.hpp"
4 #include <ctime>
5 
6 void irods::getRandomBytes( void * buf, int bytes ) {
7  if ( RAND_bytes( ( unsigned char * )buf, bytes ) != 1 ) {
8  static boost::mt19937 generator( std::time( 0 ) ^ ( getpid() << 16 ) );
9  static boost::uniform_int<unsigned char> byte_range( 0, 0xff );
10  static boost::variate_generator<boost::mt19937, boost::uniform_int<unsigned char> > random_byte( generator, byte_range );
11  for ( int i = 0; i < bytes; i++ ) {
12  ( ( unsigned char * ) buf )[i] = random_byte();
13  }
14  }
15 }
irods_random.hpp
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
irods::getRandomBytes
void getRandomBytes(void *buf, int bytes)
Definition: irods_random.cpp:6