algorithm to name files with no probability of repetition
<p>Can someone suggest a complex algorithm in php to name files that would be uploaded so that it never repeats? i wonder how youtube which has millions of videos does it??</p>

<p>Right now i use an random number and get its 16 character sha1 hash and name the file with that name but i'm pretty sure it will eventually repeat and generate an error as file will not be able to save in the file system.</p>

<p>something like:</p>

<pre><code>$name = sha1(substr(sha1(md5($randomnumber)),0,10));
</code></pre>

<p>somebody once told me that its impossible to break the hash generated by this code or at least it'll take 100 years to break it.</p>
