docs: def gen_random_key(size=32):
      """
      Generate a cryptographically-secure random key. This is done by using
      Python 2.4's os.urandom, or PyCrypto.
      """
      import os
      if hasattr(os, "urandom"): # Python 2.4+
          return os.urandom(size)
  
      # Try using PyCrypto if available
      try:
          from Crypto.Util.randpool import RandomPool
          from Crypto.Hash import SHA256
          return RandomPool(hash=SHA256).get_bytes(size)
  
      except ImportError:
          print >>sys.stderr, "WARNING: The generated key will not be cryptographically-secure key. Consider using Python 2.4+ to generate the key, or install PyCrypto."
  
          # Stupid random generation
          import random
          L = []
          for i in range(size):
              L.append(chr(random.randint(0, 255)))
          return "".join(L)