Create a checksum.
162714
private static byte[] createChecksum(final String hrp, final byte[] values)  {
        byte[] hrpExpanded = expandHrp(hrp);
        byte[] enc = new byte[hrpExpanded.length + values.length + 6];
        System.arraycopy(hrpExpanded, 0, enc, 0, hrpExpanded.length);
        System.arraycopy(values, 0, enc, hrpExpanded.length, values.length);
        int mod = polymod(enc) ^ 1;
        byte[] ret = new byte[6];
        for (int i = 0; i < 6; ++i) {
            ret[i] = (byte) ((mod >>> (5 * (5 - i))) & 31);
        }
        return ret;
    }
321888
def append_checksum(self, f, checksum):
        
        align_file_position(f, 16)
        f.write(struct.pack(b'B', checksum))
568156
def generate_checksum_bytes(payload)
      sum = payload.reduce :+
      sum_hex = ('%04x' % sum).upcase

      string_to_ascii_bytes sum_hex
    end
340220
def _checksum(cls, line):
        
        tr_table = str.maketrans({c: None for c in ascii_uppercase + "+ ."})
        no_letters = line[:68].translate(tr_table).replace("-", "1")
        return sum([int(l) for l in no_letters]) % 10
1093418
public final Checksum asChecksum() {
    return new Checksum() {

      @Override
      public long getValue() {
        return StreamingXXHash32.this.getValue() & 0xFFFFFFFL;
      }

      @Override
      public void reset() {
        StreamingXXHash32.this.reset();
      }

      @Override
      public void update(int b) {
        StreamingXXHash32.this.update(new byte[] {(byte) b}, 0, 1);
      }

      @Override
      public void update(byte[] b, int off, int len) {
        StreamingXXHash32.this.update(b, off, len);
      }

      @Override
      public String toString() {
        return StreamingXXHash32.this.toString();
      }

    };
  }
1338350
def checksum_file(scheme, path):
    """"""
    h = getattr(hashlib, scheme)()

    with open(path, 'rb') as f:
        chunk = f.read(65535)
        while chunk:
            h.update(chunk)
            chunk = f.read(65535)
    return h.hexdigest()
939758
private void verifyChunkedSums(
      byte[] data, int dataOff, int dataLen,
      byte[] checksums, int checksumsOff, String fileName,
      long basePos) throws ChecksumException {
    
    int remaining = dataLen;
    int dataPos = 0;
    while (remaining > 0) {
      int n = Math.min(remaining, bytesPerChecksum);
      
      summer.reset();
      summer.update(data, dataOff + dataPos, n);
      dataPos += n;
      remaining -= n;
      
      int calculated = (int)summer.getValue();
      int stored = (checksums[checksumsOff] << 24 & 0xff000000) |
        (checksums[checksumsOff + 1] << 16 & 0xff0000) |
        (checksums[checksumsOff + 2] << 8 & 0xff00) |
        checksums[checksumsOff + 3] & 0xff;
      checksumsOff += 4;
      if (calculated != stored) {
        long errPos = basePos + dataPos - n;
        throw new ChecksumException(
            "Checksum error: "+ fileName + " at "+ errPos +
            " exp: " + stored + " got: " + calculated, errPos);
      }
    }
  }
1290704
def parse_checksums(checksums_string):
    """"""
    checksums_list = []
    for line in checksums_string.split('\n'):
        try:
            # skip empty lines
            if line == '':
                continue

            checksum, filename = line.split()
            # strip leading ./
            if filename.startswith('./'):
                filename = filename[2:]
            checksums_list.append({'checksum': checksum, 'file': filename})
        except ValueError:
            logging.debug('Skipping over unexpected checksum line %r', line)
            continue

    return checksums_list
1000392
protected function calculateChecksum() {
        $this->checksumValue = 0;
        $c = strlen($this->text);
        for ($i = 0; $i < $c; $i++) {
            $this->checksumValue += $this->findIndex($this->text[$i]);
        }

        $this->checksumValue = $this->checksumValue % 43;
    }
1071687
static public long checksum2long(byte[] checksum, int offset, int length) {
    long crc = 0L;
    int iter = 0;
    for(int i=offset; i<offset+length; i++, iter++) {
      crc |= (0xffL&(long)checksum[i])<<((length-iter-1)*8);
    }
    return crc;
  }
824994
def checksums(self, install):
        
        check_md5(pkg_checksum(install, self.repo), self.tmp_path + install)
99376
private byte[] getChecksum(byte[] bytes) throws NoSuchProviderException, NoSuchAlgorithmException {
        byte[] d = cryptography().sha512(bytes);
        return new byte[]{d[0], d[1], d[2], d[3]};
    }
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;
}
675313
def get_checksum(self):
        """"""
        with open(self.file, 'rb') as f:
            cs = md5(f.read()).hexdigest()
        return cs
954245
def compute_checksum(line):
    """"""
    return sum((int(c) if c.isdigit() else c == '-') for c in line[0:68]) % 10
893201
def luhn_checksum(number, chars=DIGITS):
    '''
    

    '''
    length = len(chars)
    number = [chars.index(n) for n in reversed(str(number))]
    return (
        sum(number[::2]) +
        sum(sum(divmod(i * 2, length)) for i in number[1::2])
    ) % length
1007668
def generate_checksum(did, metadata):
        
        files_checksum = ''
        for file in metadata['base']['files']:
            if 'checksum' in file:
                files_checksum = files_checksum + file['checksum']
        return hashlib.sha3_256((files_checksum +
                                 metadata['base']['name'] +
                                 metadata['base']['author'] +
                                 metadata['base']['license'] +
                                 did).encode('UTF-8')).hexdigest()