Evaluate a script by sha checksum.
512047
function evalsha(req, res, sha, args) {
  this.spawn();
  this.reply(req, res, this._limit);
  // need to coerce buffers for the moment
  args = args.map(function(a) {
    if(a instanceof Buffer) return a.toString();
    return a;
  })
  this.ps.send({event: 'evalsha', sha: sha, args: args});
}
26765
def _get_checksum():
    
    digest = hashlib.sha256()
    with open(RPM_PATH, "rb") as rpm_db_fh:
        while True:
            buff = rpm_db_fh.read(0x1000)
            if not buff:
                break
            digest.update(buff)
    return digest.hexdigest()
1178128
def make_checksum_validation_script(stats_list):
    """"""
    if not os.path.exists('./hash_check'):
        os.mkdir('./hash_check')

    with open('./hash_check/curl.sh', 'w') as curl_f, open(
        './hash_check/md5.txt', 'w'
    ) as md5_f, open('./hash_check/sha1.txt', 'w') as sha1_f:

        curl_f.write('#!/usr/bin/env bash\n\n')

        for stats_dict in stats_list:
            for sysmeta_xml in stats_dict['largest_sysmeta_xml']:
                print(sysmeta_xml)
                sysmeta_pyxb = d1_common.types.dataoneTypes_v1_2.CreateFromDocument(
                    sysmeta_xml
                )

                pid = sysmeta_pyxb.identifier.value().encode('utf-8')
                file_name = re.sub('\W+', '_', pid)
                size = sysmeta_pyxb.size
                base_url = stats_dict['gmn_dict']['base_url']

                if size > 100 * 1024 * 1024:
                    logging.info('Ignored large object. size={} pid={}')

                curl_f.write('# {} {}\n'.format(size, pid))
                curl_f.write(
                    'curl -o obj/{} {}/v1/object/{}\n'.format(
                        file_name, base_url, d1_common.url.encodePathElement(pid)
                    )
                )

                if sysmeta_pyxb.checksum.algorithm == 'MD5':
                    md5_f.write(
                        '{} obj/{}\n'.format(sysmeta_pyxb.checksum.value(), file_name)
                    )
                else:
                    sha1_f.write(
                        '{} obj/{}\n'.format(sysmeta_pyxb.checksum.value(), file_name)
                    )

    with open('./hash_check/check.sh', 'w') as f:
        f.write('#!/usr/bin/env bash\n\n')
        f.write('mkdir -p obj\n')
        f.write('./curl.sh\n')
        f.write('sha1sum -c sha1.txt\n')
        f.write('md5sum -c md5.txt\n')
190839
def checksum(path):
    """"""
    hasher = hashlib.sha1()
    with open(path, 'rb') as stream:
        buf = stream.read(BLOCKSIZE)
        while len(buf) > 0:
            hasher.update(buf)
            buf = stream.read(BLOCKSIZE)
    return hasher.hexdigest()
766473
def check_merkle_hash(self):
        """"""
        calculated_hash = merkle([tx.hash() for tx in self.txs], double_sha256)
        if calculated_hash != self.merkle_root:
            raise BadMerkleRootError(
                "calculated %s but block contains %s" % (b2h(calculated_hash), b2h(self.merkle_root)))
684625
def get_checksum(self, encoder=base64.b64encode, hasher=hashlib.sha256):
        """"""
        assert self._closed, "Archive not closed"
        with open(self._temp_archive_file.name, 'rb') as fh:
            return encoder(checksum(fh, hasher())).decode('ascii')
1073047
def set_checksum(self):
        """"""
        data_sum = self.cmd1 + self.cmd2
        for i in range(1, 14):
            data_sum += self._userdata['d{:d}'.format(i)]
        chksum = 0xff - (data_sum & 0xff) + 1
        self._userdata['d14'] = chksum
99053
def script_exists(self, digest, *digests):
        """"""
        return self.execute(b'SCRIPT', b'EXISTS', digest, *digests)
354315
def valid_checksum(file, hash_file):
    
    bits = 4096
    # calc md5 hash
    hash_md5 = hashlib.md5()
    with open(file, "rb") as f:
        for chunk in iter(lambda: f.read(bits), b""):
            hash_md5.update(chunk)
    # locate hash signature for file, validate
    with open(hash_file) as c:
        for line in c.readlines():
            if line.strip():
                check_list = line.split()
                if file == check_list[1]:
                    if check_list[0] == hash_md5.hexdigest():
                        return True
    return False
371091
def check_sig(script_sig, pubkey, script_code, sig_version)
      return false if script_sig.empty?
      script_sig = script_sig.htb
      hash_type = script_sig[-1].unpack('C').first
      sig = script_sig[0..-2]
      sighash = tx.sighash_for_input(input_index, script_code, hash_type: hash_type,
                                     amount: amount, sig_version: sig_version)
      key_type = pubkey.start_with?('02') || pubkey.start_with?('03') ? Key::TYPES[:compressed] : Key::TYPES[:uncompressed]
      key = Key.new(pubkey: pubkey, key_type: key_type)
      key.verify(sig, sighash)
    end
444803
function getChecksum(fs, path, callback) {
  fs.readFile(path, function(err, data) {
    if(!err) {
      callback(null, md5sum(data));
    } else if(err.code === 'ENOENT') {
      // File does not exist so the checksum is an empty string
      callback(null, "");
    } else {
      callback(err);
    }
  });
}
582276
def eval_script(self, expr):
    
    ret = self.conn.issue_command("Evaluate", expr)
    return json.loads("[%s]" % ret)[0]
1045645
def compare_checksum(info, f):
    
    pieces = info['pieces']

    def getchunks(f, size):
        while True:
            chunk = f.read(size)
            if chunk == '':
                break
            yield hashlib.sha1(chunk).digest()

    calc = getchunks(f, info['piece length'])
    ref = (pieces[i:i + 20] for i in xrange(0, len(pieces), 20))
    for expected, actual in itertools.izip(calc, ref):
        if expected != actual:
            return False
    return ensure_empty(calc) and ensure_empty(ref)
65999
private String computeChecksum(File file) {
        try {
            ChecksumUtil cksumUtil =
                new ChecksumUtil(ChecksumUtil.Algorithm.MD5);
            return cksumUtil.generateChecksum(file);
        } catch (FileNotFoundException e) {
            throw new RuntimeException("File not found: " +
                                       file.getAbsolutePath(), e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
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;
}
15801
function checksum(data) {
	var result = data.split('').map(function (n) {
		return +n;
	}).reduce(function (sum, a, idx) {
		return idx % 2 ? sum + a * 9 : sum + a * 3;
	}, 0);
	return result % 10;
}
1195149
function getChecksum(fs, path, callback) {
  getAttr(fs, path, constants.attributes.checksum, callback);
}