Expand the HRP into values for checksum computation.
338838
def bech32_hrp_expand(hrp):
    """"""
    return [ord(x) >> 5 for x in hrp] + [0] + [ord(x) & 31 for x in hrp]
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);
      }
    }
  }
502631
def format_checksum(checksum_pyxb):
    
    return '{}/{}'.format(
        checksum_pyxb.algorithm.upper().replace('-', ''), checksum_pyxb.value().lower()
    )
1015331
def checksum(value):
    
    return chr(65 + sum(CHECKSUM_TABLE[index % 2][ALPHANUMERICS_DICT[char]]
                        for index, char in enumerate(value)) % 26)
985700
def _calc_checksum(values):
        """"""
        checksum = values[0]
        for index, value in enumerate(values):
            checksum += index * value
        return checksum % 103
706987
public function checksum($value)
    {
        if (strlen($value) == 8) {
            $this->_checksum = '_issn';
        } else {
            $this->_checksum = '_gtin';
        }

        return parent::checksum($value);
    }
1371851
def _update_checksum(self):
        """"""
        source_list = [int(octet) for octet in self.source.split(".")]
        destination_list = [int(octet) for octet in
                            self.destination.split(".")]
        source_upper = (source_list[0] << 8) + source_list[1]
        source_lower = (source_list[2] << 8) + source_list[3]
        destination_upper = (destination_list[0] << 8) + destination_list[1]
        destination_lower = (destination_list[2] << 8) + destination_list[3]

        block_sum = ((self._version_ihl << 8 | self._dscp_ecn) + self.length +
                     self.identification + self._flags_offset +
                     (self.ttl << 8 | self.protocol) + source_upper +
                     source_lower + destination_upper + destination_lower)

        while block_sum > 65535:
            carry = block_sum >> 16
            block_sum = (block_sum & 65535) + carry

        self.checksum = ~block_sum & 65535
651071
function checksum(number) {
	var res = number.substr(0, 7).split('').map(function (n) {
		return +n;
	}).reduce(function (sum, a, idx) {
		return idx % 2 ? sum + a : sum + a * 3;
	}, 0);

	return (10 - res % 10) % 10;
}
1032707
def expand_single_values(var, scans):
        """"""
        if scans.size == 1:
            return var
        else:
            expanded = np.repeat(var, scans)
            expanded.attrs = var.attrs
            expanded.rename({expanded.dims[0]: 'y'})
            return expanded
280094
def _checksum(self, packet):
        ''''''
        xorsum = 0
        for s in packet:
            xorsum ^= ord(s)
        return xorsum
1039028
def verify_checksum(*lines):
    
    for line in lines:
        checksum = line[68:69]
        if not checksum.isdigit():
            continue
        checksum = int(checksum)
        computed = compute_checksum(line)
        if checksum != computed:
            complaint = ('TLE line gives its checksum as {}'
                         ' but in fact tallies to {}:\n{}')
            raise ValueError(complaint.format(checksum, computed, line))
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;
}
390471
def checksum_creation_action(target, source, env):
    """"""

    # Important Notes:
    # There are apparently many ways to calculate a CRC-32 checksum, we use the following options
    # Initial seed value prepended to the input: 0xFFFFFFFF
    # Whether the input is fed into the shift register least-significant bit or most-significant bit first: LSB
    # Whether each data word is inverted: No
    # Whether the final CRC value is inverted: No
    # *These settings must agree between the executive and this function*

    import crcmod
    crc32_func = crcmod.mkCrcFun(0x104C11DB7, initCrc=0xFFFFFFFF, rev=False, xorOut=0)

    with open(str(source[0]), 'rb') as f:
        data = f.read()

        # Ignore the last four bytes of the file since that is where the checksum will go
        data = data[:-4]

        # Make sure the magic number is correct so that we're dealing with an actual firmware image
        magicbin = data[-4:]
        magic, = struct.unpack('<L', magicbin)

        if magic != 0xBAADDAAD:
            raise BuildError("Attempting to patch a file that is not a CDB binary or has the wrong size", reason="invalid magic number found", actual_magic=magic, desired_magic=0xBAADDAAD)

        # Calculate CRC32 in the same way as its done in the target microcontroller
        checksum = crc32_func(data) & 0xFFFFFFFF

    with open(str(target[0]), 'w') as f:
        # hex strings end with L on windows and possibly some other systems
        checkhex = hex(checksum)
        if checkhex[-1] == 'L':
            checkhex = checkhex[:-1]

        f.write("--defsym=__image_checksum=%s\n" % checkhex)
230747
function appendChecksum(diffNode, diffPath, callback) {
    rsyncUtils.getChecksum(fs, diffPath, function(err, checksum) {
      if(err) {
        return callback(err);
      }

      diffNode.checksum = checksum;
      diffList.push(diffNode);

      callback(null, diffList);
    });
  }
1221904
function computeChecksums(out, filenames) {
	var result = {};
	filenames.forEach(function (filename) {
		var fullPath = path.join(process.cwd(), out, filename);
		result[filename] = computeChecksum(fullPath);
	});
	return result;
}
731321
def compute_checksum(&block)
      crc = CRC.new
      # Have to read this first because it might change the seek position.
      file_size = header.file_size
      @io.seek(8, IO::SEEK_SET)
      pos = 8
      length = 4096-8
      buf = nil
      while true
        buf = @io.read(length, buf)
        break if !buf
        crc.update(buf)
        pos += buf.size
        block.call(pos) if block
        length = 4096
      end
      crc.crc
    end
1207457
public static String encode(String hrp, final byte[] values) {
        checkArgument(hrp.length() >= 1, "Human-readable part is too short");
        checkArgument(hrp.length() <= 83, "Human-readable part is too long");
        hrp = hrp.toLowerCase(Locale.ROOT);
        byte[] checksum = createChecksum(hrp, values);
        byte[] combined = new byte[values.length + checksum.length];
        System.arraycopy(values, 0, combined, 0, values.length);
        System.arraycopy(checksum, 0, combined, values.length, checksum.length);
        StringBuilder sb = new StringBuilder(hrp.length() + 1 + combined.length);
        sb.append(hrp);
        sb.append('1');
        for (byte b : combined) {
            sb.append(CHARSET.charAt(b));
        }
        return sb.toString();
    }