title: Generating random string of seedable data
body: <p>I'm looking for a way to generate a random string of <em>n</em> bytes in Python in a similar way to <code>os.urandom()</code> method except providing a way to seed the data generation.</p>
  
  <p>So far I have:</p>
  
  <pre><code>def genRandData(size):
      buf = chr(random.randint(0,255))
      for i in range(size-1):
          buf = buf + chr(random.randint(0,255))
      return str(buf)
  </code></pre>
  
  <p>However this function is very slow, generating a megabyte of data takes about 1.8 seconds on my machine. Is there any way of improving this (or alternatively a way to seed os.urandom).</p>