}
/**
- * returns $bytes bytes of random data as a hexadecimal string
+ * returns $bytes bytes of raw random data
*/
-function common_random_hexstr($bytes)
+function common_random_rawstr($bytes)
{
- $str = @file_exists('/dev/urandom')
+ $rawstr = @file_exists('/dev/urandom')
? common_urandom($bytes)
: common_mtrand($bytes);
+ return $rawstr;
+}
+
+/**
+ * returns $bytes bytes of random data as a hexadecimal string
+ */
+function common_random_hexstr($bytes)
+{
+ $str = common_random_rawstr($bytes);
+
$hexstr = '';
for ($i = 0; $i < $bytes; $i++) {
$hexstr .= sprintf("%02x", ord($str[$i]));