library/src/utility/BP-StringUtilities.cc
// creates a string containing pseudorandom unsigned char data.
creates a string containing pseudorandom unsigned char data.
creates a string containing pseudorandom unsigned char data .
unsigned char * BP_GenRandomUnsignedCharString(size_t len)
{
	if(!len)
		return NULL;
	unsigned char *random_str = (unsigned char *) bpcalloc(len+1, 1);
	if(!random_str)
		return NULL;
	size_t n = 0;
	unsigned char curr_char = 0x00;
	BP_SeedPNRG();
	for(; n < len; n++)
	{
		random_str[n] = (unsigned char) rand();
	}
	return random_str;
}
unsigned char * BP_GenRandomUnsignedCharString ( size_t len ) { if ( ! len ) return NULL ; unsigned char * random_str = ( unsigned char * ) bpcalloc ( len + 1 , 1 ) ; if ( ! random_str ) return NULL ; size_t n = 0 ; unsigned char curr_char = 0x00 ; BP_SeedPNRG ( ) ; for ( ; n < len ; n ++ ) { random_str [ n ] = ( unsigned char ) rand ( ) ; } return random_str ; }
creates a string containing pseudorandom unsigned char data.
creates a string containing pseudorandom unsigned char data .
// run length check // allocate space for the ascii string // check to ensure data was allocated // generate the random string // seed random with loose seed (not secure data) // walk and create random string // set the character after its validated // return the random string data