Compute hash of each payload block.
    Used to prevent payload corruption and tampering.
423020
def compute_payload_block_hash(this):
    """"""

    return hmac.new(
        hashlib.sha512(
            struct.pack('<Q', this._index) +
            hashlib.sha512(
                this._._.header.value.dynamic_header.master_seed.data +
                this._.transformed_key + b'\x01'
            ).digest()
        ).digest(),
        struct.pack('<Q', this._index) +
        struct.pack('<I', len(this.block_data)) +
        this.block_data, hashlib.sha256
    ).digest()
140449
def verify_hash(self, hashed_data, compare_data):
        
        return self.security.hashing_context.verify(
            encode_string(compare_data), hashed_data)
458734
def _hash(self):
        
        dump = dumps(self.query, sort_keys=True)
        if isinstance(dump, str):
            dump = dump.encode('utf-8')
        return md5(dump).hexdigest()
130911
def hash(self):
        '''
        
        '''
        hashed = super(RandomBits, self).hash()
        return khash(hashed, self._min_length, self._max_length, self._num_mutations, self._step, self._seed)
398353
def make_hash(s, n_bytes):
    """"""
    raw_h = int(md5(s.encode('utf-8')).hexdigest()[:n_bytes], 16)
    # Make it a signed int.
    return 16**n_bytes//2 - raw_h
124274
def mix_hash(self, data: bytes):
        
        self.h = self.noise_protocol.hash_fn.hash(self.h + data)
436501
public static void hash(byte[] data, byte[] output) {
    int len = output.length;
    if (len == 0)
      return;
    int[] code = calculate(data);
    for (int outIndex = 0, codeIndex = 0, shift = 24;
            outIndex < len && codeIndex < 5;
                ++outIndex, shift -= 8) {
      output[outIndex] = (byte) (code[codeIndex] >>> shift);
      if (shift == 0) {
        shift = 32;     // will be decremented by 8 before next iteration
        ++codeIndex;
      }
    }
  }
366671
def compute_file_hashes(file_path, hashes=frozenset(['md5'])):
    
    if not os.path.exists(file_path):
        logging.warning("%s does not exist" % file_path)
        return
    else:
        logging.debug("Computing [%s] hashes for file [%s]" % (','.join(hashes), file_path))

    try:
        with open(file_path, 'rb') as fd:
            return compute_hashes(fd, hashes)
    except (IOError, OSError) as e:
        logging.warning("Error while calculating digest(s) for file %s: %s" % (file_path, str(e)))
        raise
707333
def block_header_verify( block_data, prev_hash, block_hash ):
    
    serialized_header = block_header_to_hex( block_data, prev_hash )
    candidate_hash_bin_reversed = hashing.bin_double_sha256(binascii.unhexlify(serialized_header))
    candidate_hash = binascii.hexlify( candidate_hash_bin_reversed[::-1] )

    return block_hash == candidate_hash
430528
def calculate_hash(options):
        """"""
        options = sorted(list(options))
        sha_hash = sha1()
        # equivalent to loop over the options and call sha_hash.update()
        sha_hash.update(''.join(options).encode('utf-8'))
        return sha_hash.hexdigest()
1021642
def hash(self):
        '''
        
        '''
        hashed = super(TakeFrom, self).hash()
        return khash(hashed, self.min_elements, self.max_elements, self.seed)
621752
def calculate_hashes(self):
        
        hashers = []
        if not self.mardata.signatures:
            return []

        for s in self.mardata.signatures.sigs:
            h = make_hasher(s.algorithm_id)
            hashers.append((s.algorithm_id, h))

        for block in get_signature_data(self.fileobj, self.mardata.signatures.filesize):
            [h.update(block) for (_, h) in hashers]

        return [(algo_id, h.finalize()) for (algo_id, h) in hashers]
93391
def to_hash
        h = {}
        keys.each { |k| h[ k ] = self.fetch( k ) }
        h
    end
90150
def return_hash(final_vector)
      case digest_length
      when 512
        create_digest(final_vector)
      when 256
        create_digest(vector_from_array(final_vector[0..31]))
      else
        raise ArgumentError,
              "digest length must be equal to 256 or 512, not #{digest_length}"
      end
    end
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;
}
607070
def hash(self):
        """"""
        if self._hash is None:
            m = hashlib.new('md5')
            if self._preprocessor is None:
                # generate hash from numpy array
                m.update(numpy_buffer(self._X_train))
                m.update(numpy_buffer(self._y_train))
                if self._X_test is not None:
                    m.update(numpy_buffer(self._X_test))
                if self._y_test is not None:
                    m.update(numpy_buffer(self._y_test))
            elif callable(self._preprocessor):
                # generate hash from user defined object (source code)
                m.update(inspect.getsource(self._preprocessor).encode('utf-8'))

            self._hash = m.hexdigest()

        return self._hash
563962
def hash(self, build_context) -> str:
        """"""
        if self._hash is None:
            self.compute_hash(build_context)
        return self._hash