title: safe enough 8-character short unique random string
body: <p>I am trying to compute 8-character short unique random filenames for, let's say, thousands of files without probable name collision. Is this method safe enough?</p>
  
  <pre><code>base64.urlsafe_b64encode(hashlib.md5(os.urandom(128)).digest())[:8]
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>To be clearer, I am trying to achieve simplest possible obfuscation of filenames being uploaded to a storage.</p>
  
  <p>I figured out that 8-character string, random enough, would be very efficient and simple way to store tens of thousands of files without probable collision, when implemented right. I don't need guaranteed uniqueness, only high-enough improbability of name collision (talking about only thousands of names).</p>
  
  <p>Files are being stored in concurrent environment, so incrementing shared counter is achievable, but complicated. Storing counter in database would be inefficient.</p>
  
  <p>I am also facing the fact that random() under some circumstances returns <em>same</em> pseudorandom sequences in <em>different</em> processes.</p>