code: def genkeyhex():
      '''
      Generate new random Bitcoin private key, using os.urandom and
      double-sha256.  Hex format.
      '''
  
      while True:
          key = hash256(
                  hexlify(os.urandom(40) + str(datetime.datetime.now())
                                              .encode("utf-8")))
          # 40 bytes used instead of 32, as a buffer for any slight
          #     lack of entropy in urandom
          # Double-sha256 used instead of single hash, for entropy
          #     reasons as well.
          # I know, it's nit-picking, but better safe than sorry.
  
          if int(key,16) > 1 and int(key,16) < N:
              break
      return kef genkeyhex():
      '''
      Generate new random Bitcoin private key, using os.urandom and
      double-sha256.  Hex format.
      '''
  
      while True:
          key = hash256(
                  hexlify(os.urandom(40) + str(datetime.datetime.now())
                                              .encode("utf-8")))
          # 40 bytes used instead of 32, as a buffer for any slight
          #     lack of entropy in urandom
          # Double-sha256 used instead of single hash, for entropy
          #     reasons as well.
          # I know, it's nit-picking, but better safe than sorry.
  
          if int(key,16) > 1 and int(key,16) < N:
              break
      return key
docs: Generate new random Bitcoin private key, using os.urandom and
      double-sha256.  Hex format.