So once upon a time I used
$key = time().".".getmypid();
For a UID (unique ID) in PHP. Maybe I wanted things to sort a bit? But of course there's always plain old
$key = uniqid("",true);
(which says "" for prefix, and more entropy.)
if(preg_match('/[^\.a-z_\-0-9]/i', $id)){
echo "bad id";
}
could be a check if you're using this for a filename, and want to make sure it's not too dangerous to try and open... (shenanigans changing the folder or escaping out)
No comments:
Post a Comment