Very useful function that only accepts records with a numeric start to
    their sha-1 hash.
338755
def hash_starts_numeric(records):
    
    for record in records:
        seq_hash = hashlib.sha1(str(record.seq)).hexdigest()
        if seq_hash[0].isdigit():
            yield record
1257072
def ensureHashIndex(self, fields, unique = False, sparse = True, deduplicate = False) :
        """"""
        data = {
            "type" : "hash",
            "fields" : fields,
            "unique" : unique,
            "sparse" : sparse,
            "deduplicate": deduplicate
        }
        ind = Index(self, creationData = data)
        self.indexes["hash"][ind.infos["id"]] = ind
        return ind
180634
def digest_sha1(*files)
      files.flatten.collect { |file| 
        File.exists?(file) ? Digest::SHA1.hexdigest(File.read(file)) : nil
      }
    end
816641
function sha1(str) {
	      var utf8 = utf8Encode(str);
	      var words32 = stringToWords32(utf8);
	      var len = utf8.length * 8;
	      var w = new Array(80);
	      var _a = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4];
	      words32[len >> 5] |= 0x80 << (24 - len % 32);
	      words32[((len + 64 >> 9) << 4) + 15] = len;
	      for (var i = 0; i < words32.length; i += 16) {
	          var _b = [a, b, c, d, e], h0 = _b[0], h1 = _b[1], h2 = _b[2], h3 = _b[3], h4 = _b[4];
	          for (var j = 0; j < 80; j++) {
	              if (j < 16) {
	                  w[j] = words32[i + j];
	              }
	              else {
	                  w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
	              }
	              var _c = fk(j, b, c, d), f = _c[0], k = _c[1];
	              var temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
	              _d = [d, c, rol32(b, 30), a, temp], e = _d[0], d = _d[1], c = _d[2], b = _d[3], a = _d[4];
	          }
	          _e = [add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)], a = _e[0], b = _e[1], c = _e[2], d = _e[3], e = _e[4];
	      }
	      var sha1 = words32ToString([a, b, c, d, e]);
	      var hex = '';
	      for (var i = 0; i < sha1.length; i++) {
	          var b_1 = sha1.charCodeAt(i);
	          hex += (b_1 >>> 4 & 0x0f).toString(16) + (b_1 & 0x0f).toString(16);
	      }
	      return hex.toLowerCase();
	      var _d, _e;
	  }
466862
def key_hash_algo(self, value):
        

        if value not in set(['sha1', 'sha256']):
            raise ValueError(_pretty_message(
                '''
                hash_algo must be one of "sha1", "sha256", not %s
                ''',
                repr(value)
            ))

        self._key_hash_algo = value
1322768
function checkVhash(i) {
  const start = i;
  let l;

  if (i >= tokensLength) return 0;

  // Skip `#`.
  if (tokens[i].type === TokenType.NumberSign) i++;
  else return 0;

  if (l = checkNmName2(i)) i += l;
  else return 0;

  return i - start;
}
143552
def _pkcs1imify(self, data):
        
        SHA1_DIGESTINFO = '\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14'
        size = len(util.deflate_long(self.n, 0))
        filler = '\xff' * (size - len(SHA1_DIGESTINFO) - len(data) - 3)
        return '\x00\x01' + filler + '\x00' + SHA1_DIGESTINFO + data
217176
def sighash_for_witness(index, script_pubkey_or_script_code, hash_type, amount, skip_separator_index)
      hash_prevouts = Bitcoin.double_sha256(inputs.map{|i|i.out_point.to_payload}.join)
      hash_sequence = Bitcoin.double_sha256(inputs.map{|i|[i.sequence].pack('V')}.join)
      outpoint = inputs[index].out_point.to_payload
      amount = [amount].pack('Q')
      nsequence = [inputs[index].sequence].pack('V')
      hash_outputs = Bitcoin.double_sha256(outputs.map{|o|o.to_payload}.join)

      script_code = script_pubkey_or_script_code.to_script_code(skip_separator_index)

      case (hash_type & 0x1f)
      when SIGHASH_TYPE[:single]
        hash_outputs = index >= outputs.size ? "\x00".ljust(32, "\x00") : Bitcoin.double_sha256(outputs[index].to_payload)
        hash_sequence = "\x00".ljust(32, "\x00")
      when SIGHASH_TYPE[:none]
        hash_sequence = hash_outputs = "\x00".ljust(32, "\x00")
      end

      if (hash_type & SIGHASH_TYPE[:anyonecanpay]) != 0
        hash_prevouts = hash_sequence ="\x00".ljust(32, "\x00")
      end
      hash_type |= (Bitcoin.chain_params.fork_id << 8) if Bitcoin.chain_params.fork_chain?
      buf = [ [version].pack('V'), hash_prevouts, hash_sequence, outpoint,
              script_code ,amount, nsequence, hash_outputs, [@lock_time, hash_type].pack('VV')].join
      Bitcoin.double_sha256(buf)
    end
554475
function getSha256Hash (stringToSign, format) {
	if(!format) {
		stringToSign = naclInstance.encode_utf8(stringToSign);
	} else if(format === 'utf8') {
		stringToSign = naclInstance.encode_utf8(stringToSign);
	} else if(format === 'hex') {
		stringToSign = naclInstance.from_hex(stringToSign);
	}

	return naclInstance.crypto_hash_sha256(stringToSign);
	// return crypto.createHash('sha256').update(stringToSign, format).digest();
}
572747
def read_sha1(
    file_path,
    buf_size = None,
    start_byte = 0,
    read_size = None,
    extra_hashers = [], # update(data) will be called on all of these
):
    '''
    
    '''
    read_size = read_size or os.stat(file_path).st_size
    buf_size = buf_size or DEFAULT_BUFFER_SIZE

    data_read = 0
    total_sha1 = hashlib.sha1()
    while data_read < read_size:
        with open( file_path, 'rb', buffering = 0 ) as f:
            f.seek( start_byte )
            data = f.read( min(buf_size, read_size - data_read) )
            assert( len(data) > 0 )
            total_sha1.update( data )
            for hasher in extra_hashers:
                hasher.update( data )
            data_read += len(data)
            start_byte += len(data)
    assert( data_read == read_size )

    return total_sha1
1353696
public static byte[] sha1(@NotNull byte[] input, @Nullable byte[] salt) {
		return digest(input, get(SHA_1_DIGEST), salt, 1);
	}
1334653
def sha_hash_file(filename):
    
    hash_sha = hashlib.sha1()

    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(1024*1024), b""):
            hash_sha.update(chunk)

    return hash_sha.hexdigest()
992188
function getHash(location) {
    var href = location.href;
    var hashIndex = href.indexOf('#');

    if (hashIndex === -1) {
      return '';
    } else {
      return href.substr(hashIndex);
    }
  }
723749
function getNumericHash(data) {
	var hash = crypto.createHash('md5'),
		numeric = 0,
		buf;
	hash.update(data + '-Phonetic');
	buf = hash.digest();
	for (var i = 0; i <= 12; i += 4)
		numeric += buf.readUInt32LE(i);
	return numeric;
}
1077580
def sha1sum_numpy(np_array):
    '''
    
    '''
    import hashlib
    return hashlib.sha1(np_array.view(np.uint8)).hexdigest()
60100
public function sha1($format = null, $raw_output = false)
	{
		return hash('sha1', parent::format($format === null ? static::$format : $format), $raw_output);
	}
1050211
function trimHash (uri) {
	var indexOfHash = uri.indexOf('#');
	return (indexOfHash != -1) ? uri.substring(0, indexOfHash) : uri;
}