public static function GenerateRandomKey($length = 128)
{
//Is there windows os?
if (DIRECTORY_SEPARATOR === '\\') {
//windows os
$rnd = '';
$t = ceil($length / 40);
for ($i = 0; $i < $t; ++$i) {
$rnd .= sha1(uniqid());
}
} else {
//unix os
$rnd = file_get_contents('/dev/urandom', null, null, 0, $length);
}
$key = substr(base64_encode($rnd), 0, $length);
return $key;
}