echo random_bytes($length);
$str=random_bytes(7); echo bin2hex($str);
cf838f8c5b6cd2
Post your comments , suggestion , error , requirements etc here