code: def get_nonzero_random_bytes(length, rnd=default_crypto_random):
      '''
         Accumulate random bit string and remove \0 bytes until the needed length
         is obtained.
      '''
      result = []
      i = 0
      while i < length:
          rnd = rnd.getrandbits(12*length)
          s = i2osp(rnd, 3*length)
          s = s.replace('\x00', '')
          result.append(s)
          i += len(s)
      return (''.join(result))[:lengthf get_nonzero_random_bytes(length, rnd=default_crypto_random):
      '''
         Accumulate random bit string and remove \0 bytes until the needed length
         is obtained.
      '''
      result = []
      i = 0
      while i < length:
          rnd = rnd.getrandbits(12*length)
          s = i2osp(rnd, 3*length)
          s = s.replace('\x00', '')
          result.append(s)
          i += len(s)
      return (''.join(result))[:length]
docs: Accumulate random bit string and remove \0 bytes until the needed length
         is obtained.