Generates a random table based mini-hashing function.
326011
def generate_func(self, table):
        

        # Ensure that `self` isn't suddenly in the closure...
        n = self.n

        def func(word):
            return sum(x * ord(c) for x, c in zip(table, word)) % n

        return func
53287
def generate_random_id(method)
      data = File.open("/dev/urandom", "rb") do |f|
        f.read(64)
      end
      case method
      when :base64
        data = base64(data)
        data.gsub!("+", '')
        data.gsub!("/", '')
        data.gsub!(/==$/, '')
        return data
      when :hex
        return data.unpack('H*')[0]
      else
        raise ArgumentError, "Invalid method #{method.inspect}"
      end
    end
924437
function deterministicGenerateK (hash, x, checkSig) {
  typeforce(types.tuple(
    types.Hash256bit,
    types.Buffer256bit,
    types.Function
  ), arguments);

  // Step A, ignored as hash already provided
  // Step B
  // Step C
  let k = Buffer.alloc(32, 0);
  let v = Buffer.alloc(32, 1);

  // Step D
  k = createHmac('sha256', k)
    .update(v)
    .update(ZERO)
    .update(x)
    .update(hash)
    .digest();

  // Step E
  v = createHmac('sha256', k).update(v).digest();

  // Step F
  k = createHmac('sha256', k)
    .update(v)
    .update(ONE)
    .update(x)
    .update(hash)
    .digest();

  // Step G
  v = createHmac('sha256', k).update(v).digest();

  // Step H1/H2a, ignored as tlen === qlen (256 bit)
  // Step H2b
  v = createHmac('sha256', k).update(v).digest();

  let T = BigInteger.fromBuffer(v);

  // Step H3, repeat until T is within the interval [1, n - 1] and is suitable for ECDSA
  while (T.signum() <= 0 || T.compareTo(secp256k1.n) >= 0 || !checkSig(T)) {
    k = createHmac('sha256', k)
      .update(v)
      .update(ZERO)
      .digest();

    v = createHmac('sha256', k).update(v).digest();

    // Step H1/H2a, again, ignored as tlen === qlen (256 bit)
    // Step H2b again
    v = createHmac('sha256', k).update(v).digest();
    T = BigInteger.fromBuffer(v);
  }

  return T;
}
752737
function generate(length) {
    var len = length - 1;
    var ary = new Array(len);
    for (var i = 0; i < len; i++) {
      ary.push(Math.floor(Math.random() * 10));
    }
    var num = ary.join('');
    return num + '' + checkSum(num);
  }
613952
def random_id_generator(self, size=6, chars=string.ascii_uppercase +
                            string.digits):
        '''  '''
        return ''.join(random.choice(chars) for x in range(size))
128118
def make_data(n):
    """"""
    V = range(1,n+1)
    x = dict([(i, random.random()) for i in V])
    y = dict([(i, random.random()) for i in V])
    c, q = {}, {}
    Q = 100
    for i in V:
        q[i] = random.randint(10, 20)
        for j in V:
            if j > i:
                c[i, j] = distance(x[i], y[i], x[j], y[j])
    return V, c, q, Q
148007
def randombytes(n):
    """"""
    # Use /dev/urandom if it is available.  Fall back to random module
    # if not.  It might be worthwhile to extend this function to use
    # other platform-specific mechanisms for getting random bytes.
    if os.path.exists("/dev/urandom"):
        f = open("/dev/urandom")
        s = f.read(n)
        f.close()
        return s
    else:
        L = [chr(random.randrange(0, 256)) for i in range(n)]
        return "".join(L)
211518
function random_bytes(count) {
        var bs = new Uint8Array(count);
        if (typeof (window.crypto) !== "undefined") {
          if (typeof (window.crypto.getRandomValues) !== "undefined") {
            window.crypto.getRandomValues(bs);
            return bs;
          }
        }
        if (typeof (window.msCrypto) !== "undefined") {
          if (typeof (window.msCrypto.getRandomValues) !== "undefined") {
            window.msCrypto.getRandomValues(bs);
            return bs;
          }
        }
        throw {
          message: "No suitable random number generator found!"
        };
      }
1051435
def generate_random_level(self):
        

        # build !
        width = self.width
        height = self.height
        tiles_w = self.tiles_w
        tiles_h = self.tiles_h
        self.z = 0

        # add walls
        #self.map_layer = ti.load(os.path.join(script_dir, 'test.tmx'))['map0']
        self.map_layer = self.generator.map(tiles_w, tiles_h)
        self.map_layer.set_view(0, 0, self.map_layer.px_width, self.map_layer.px_height)
        # FIXME: Both `scale_x` and `scale_y`
        self.map_layer.scale = config.scale_x
        self.add(self.map_layer, z=self.z)
        self.z += 1

        # add floor
        # TODO: Move to `Generator.inverse(map)`
        self.visit_layer = ti.load(os.path.join(script_dir, 'assets', 'ones.tmx'))['map0']
        for i in xrange(0, len(self.map_layer.cells)):
            for j in xrange(0, len(self.map_layer.cells[i])):
                col = self.map_layer.cells[i][j]
                # If wall exists, remove floor
                if col.tile and col.tile.id > 0:
                    self.visit_layer.cells[i][j].tile = None

        self.visit_layer.set_view(0, 0, self.visit_layer.px_width, self.visit_layer.px_height)
        # FIXME: Both `scale_x` and `scale_y`
        self.visit_layer.scale = config.scale_x
        self.add(self.visit_layer, z=-1)

        # add player
        # Start in random corner
        corner = randint(0,3)
        padding = eu.Vector2(self.map_layer.tw*1.5, self.map_layer.th*1.5)
        corners = [
            eu.Vector2(padding.x, padding.y), # Bottom left
            eu.Vector2(((tiles_w+1)*self.map_layer.tw)-padding.x, padding.y), # Bottom right
            eu.Vector2(padding.x, ((tiles_h+1)*self.map_layer.th)-padding.y), # Top right
            eu.Vector2(((tiles_w+1)*self.map_layer.tw)-padding.x, ((tiles_h+1)*self.map_layer.th)-padding.y) # Top left
        ]
        rotations = [
            45,
            -45,
            135,
            -135
        ]
        self.spawn = corners[corner]
        self.player = Player(self.spawn.x, self.spawn.y)
        self.player.rotation = rotations[corner]
        self.add(self.player, z=self.z)
        self.z += 1

        self.score = ScoreLayer(self.player.stats)
        self.add(self.score, z=self.z)
        self.z += 1

        # Draw sensors
        # TODO: Decouple into view rendering
        a = math.radians(self.player.rotation)
        for sensor in self.player.sensors:
            rad = a + sensor.angle
            start = self.player.cshape.center
            end = start.copy()
            end.x += math.sin(rad) * sensor.proximity;
            end.y += math.cos(rad) * sensor.proximity;
            sensor.line = draw.Line(start, end, self.player.palette['wall'] + (int(255*0.5),))
            self.map_layer.add(sensor.line)

        # Generate obstacles
        self.create_items()
966326
def generate_key(s, pattern="%s.txt"):
    
    h = hashlib.sha1()
    #h.update(s)
    h.update(s.encode('utf-8'))
    return pattern % h.hexdigest()
920958
function createHashtable(checksums) {
  var hashtable = {};
  var len = checksums.length;
  var checksum;
  var weak16;

  for (var i = 0; i < len; i++) {
    checksum = checksums[i];
    weak16 = calcWeak16(checksum.weak);
    if (hashtable[weak16]) {
      hashtable[weak16].push(checksum);
    } else {
      hashtable[weak16] = [checksum];
    }
  }
  return hashtable;
}
1227513
function roll(data, checksums, blockSize) {
  var results = [];
  var hashtable = createHashtable(checksums);
  var length = data.length;
  var start = 0;
  var end = blockSize > length ? length : blockSize;
  // Updated when a block matches
  var lastMatchedEnd = 0;
  // This gets updated every iteration with the previous weak 32bit hash
  var prevRollingWeak = null;
  var weak;
  var weak16;
  var match;
  var d;
  var len;
  var mightMatch;
  var chunk;
  var strong;
  var hashtable_weak16;
  var hashtable_weak16i;

  for (; end <= length; start++, end++) {
    weak = calcWeak32(data, prevRollingWeak, start, end);
    weak16 = calcWeak16(weak.sum);
    match = false;
    d = null;
    prevRollingWeak = weak;
    hashtable_weak16 = hashtable[weak16];

    if (hashtable_weak16) {
      len = hashtable_weak16.length;
      for (var i = 0; i < len; i++) {
        hashtable_weak16i = hashtable_weak16[i];
        if (hashtable_weak16i.weak === weak.sum) {
          mightMatch = hashtable_weak16i;
          chunk = data.slice(start, end);
          strong = md5sum(chunk);

          if (mightMatch.strong === strong) {
            match = mightMatch;
            break;
          }
        }
      }
    }
    if (match) {
      if(start < lastMatchedEnd) {
        d = data.slice(lastMatchedEnd - 1, end);
        results.push({
          data: d,
          index: match.index
        });
      } else if (start - lastMatchedEnd > 0) {
        d = data.slice(lastMatchedEnd, start);
        results.push({
          data: d,
          index: match.index
        });
      } else {
        results.push({
          index: match.index
        });
      }
      lastMatchedEnd = end;
    } else if (end === length) {
      // No match and last block
      d = data.slice(lastMatchedEnd);
      results.push({
        data: d
      });
    }
  }
  return results;
}
525944
private function generarId()
    {
        if (function_exists('random_bytes')) {
            $semilla = random_bytes(32);
        } elseif (function_exists('mcrypt_create_iv')) {
            $semilla = mcrypt_create_iv(32, MCRYPT_DEV_URANDOM);
        } elseif (function_exists('openssl_random_pseudo_bytes')) {
            $semilla = openssl_random_pseudo_bytes(32);
        } else {
            $semilla = uniqid('armazon', true);
        }

        return hash('sha256', $semilla);
    }
1299926
def random_hash(size=9999999999, hash_type=None):
    '''
    
    '''
    if not hash_type:
        hash_type = 'md5'
    hasher = getattr(hashlib, hash_type)
    return hasher(salt.utils.stringutils.to_bytes(six.text_type(random.SystemRandom().randint(0, size)))).hexdigest()
97053
def generateRandomSDRVaryingSparsity(numSDR, numDims, minSparsity, maxSparsity,
                                     seed=42):
  
  randomSDRs = np.zeros((numSDR, numDims), dtype=uintType)
  indices = np.array(range(numDims))
  np.random.seed(seed)
  for i in range(numSDR):
    sparsity = np.random.random() * (maxSparsity - minSparsity) + minSparsity
    numActiveInputBits = int(sparsity * numDims)
    randomIndices = np.random.permutation(indices)
    activeBits = randomIndices[:numActiveInputBits]
    randomSDRs[i, activeBits] = 1
  return randomSDRs
1310158
def merkle_pair(hashes, hash_f):
    """"""
    if len(hashes) % 2 == 1:
        hashes = list(hashes)
        hashes.append(hashes[-1])
    items = []
    for i in range(0, len(hashes), 2):
        items.append(hash_f(hashes[i] + hashes[i+1]))
    return items
1023870
def simulate(self):
        """"""
        min_ = (-sys.maxsize - 1) if self._min is None else self._min
        max_ = sys.maxsize if self._max is None else self._max
        return random.randint(min_, max_)