// Checksum returns CRC checksum of data usign scpecified algorithm represented by the Table.
517603
func Checksum(data []byte, table *Table) uint16 {
	crc := Init(table)
	crc = Update(crc, data, table)
	return Complete(crc, table)
}
250636
func GenerateChecksum(data []byte) byte {
	var offset int
	ret := data[offset]
	for i := offset + 1; i < len(data)-1; i++ {
		// Xor bytes
		ret ^= data[i]
	}
	// Not result
	ret = (byte)(^ret)
	return ret
}
599425
func RetrieveChecksum(in IndexInput) (int64, error) {
	var err error
	if err = in.Seek(in.Length() - FOOTER_LENGTH); err != nil {
		return 0, err
	}
	if err = validateFooter(in); err != nil {
		return 0, err
	}
	return in.ReadLong()
}
32422
func (s *CreateIntentVersionInput) SetChecksum(v string) *CreateIntentVersionInput {
	s.Checksum = &v
	return s
}
1210185
func checksum(input []byte) (cksum [4]byte) {
	h := sha256.Sum256(input)
	h2 := sha256.Sum256(h[:])
	copy(cksum[:], h2[:4])
	return
}
801162
func fileChecksum(path string) (string, error) {
	data, err := ioutil.ReadFile(path)
	if err != nil {
		return "", err
	}
	hash := sha1.New()
	io.WriteString(hash, string(data))
	return fmt.Sprintf("%x", hash.Sum(nil)), nil
}
1227682
func (res *Response) Checksum() string {
	h := sha1.New()
	h.Write(res.Body)
	return strings.ToLower(hex.EncodeToString(h.Sum(nil)))
}
964843
func (b ICMPv4) SetChecksum(checksum uint16) {
	binary.BigEndian.PutUint16(b[2:], checksum)
}
1181491
func (d *digest) checkSum() (digest [Size]byte) {
	n := d.nx

	var k [64]byte
	copy(k[:], d.x[:n])

	k[n] = 0x80

	if n >= 56 {
		block(d, k[:])

		// clear block buffer - go compiles this to optimal 1x xorps + 4x movups
		// unfortunately expressing this more succinctly results in much worse code
		k[0] = 0
		k[1] = 0
		k[2] = 0
		k[3] = 0
		k[4] = 0
		k[5] = 0
		k[6] = 0
		k[7] = 0
		k[8] = 0
		k[9] = 0
		k[10] = 0
		k[11] = 0
		k[12] = 0
		k[13] = 0
		k[14] = 0
		k[15] = 0
		k[16] = 0
		k[17] = 0
		k[18] = 0
		k[19] = 0
		k[20] = 0
		k[21] = 0
		k[22] = 0
		k[23] = 0
		k[24] = 0
		k[25] = 0
		k[26] = 0
		k[27] = 0
		k[28] = 0
		k[29] = 0
		k[30] = 0
		k[31] = 0
		k[32] = 0
		k[33] = 0
		k[34] = 0
		k[35] = 0
		k[36] = 0
		k[37] = 0
		k[38] = 0
		k[39] = 0
		k[40] = 0
		k[41] = 0
		k[42] = 0
		k[43] = 0
		k[44] = 0
		k[45] = 0
		k[46] = 0
		k[47] = 0
		k[48] = 0
		k[49] = 0
		k[50] = 0
		k[51] = 0
		k[52] = 0
		k[53] = 0
		k[54] = 0
		k[55] = 0
		k[56] = 0
		k[57] = 0
		k[58] = 0
		k[59] = 0
		k[60] = 0
		k[61] = 0
		k[62] = 0
		k[63] = 0
	}
	binary.BigEndian.PutUint64(k[56:64], uint64(d.len)<<3)
	block(d, k[:])

	{
		const i = 0
		binary.BigEndian.PutUint32(digest[i*4:i*4+4], d.h[i])
	}
	{
		const i = 1
		binary.BigEndian.PutUint32(digest[i*4:i*4+4], d.h[i])
	}
	{
		const i = 2
		binary.BigEndian.PutUint32(digest[i*4:i*4+4], d.h[i])
	}
	{
		const i = 3
		binary.BigEndian.PutUint32(digest[i*4:i*4+4], d.h[i])
	}
	{
		const i = 4
		binary.BigEndian.PutUint32(digest[i*4:i*4+4], d.h[i])
	}
	{
		const i = 5
		binary.BigEndian.PutUint32(digest[i*4:i*4+4], d.h[i])
	}
	{
		const i = 6
		binary.BigEndian.PutUint32(digest[i*4:i*4+4], d.h[i])
	}
	{
		const i = 7
		binary.BigEndian.PutUint32(digest[i*4:i*4+4], d.h[i])
	}

	return
}
361011
func (s *CreateBotVersionInput) SetChecksum(v string) *CreateBotVersionInput {
	s.Checksum = &v
	return s
}
1257410
func (s *GetIntentOutput) SetChecksum(v string) *GetIntentOutput {
	s.Checksum = &v
	return s
}
701259
func ChecksumForFile(path string) ([]byte, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	return ChecksumForReader(f)
}
595404
func Checksum(path string) (checksum string, err error) {
	// Open executable
	var f *os.File
	if f, err = os.Open(path); err != nil {
		err = errors.Wrapf(err, "opening %s failed", path)
		return
	}
	defer f.Close()

	// Compute checksum
	var h = sha1.New()
	if _, err = io.Copy(h, f); err != nil {
		err = errors.Wrap(err, "copying file to hasher failed")
		return
	}
	checksum = base64.StdEncoding.EncodeToString(h.Sum(nil))
	return
}
850864
func (s *PutBotAliasInput) SetChecksum(v string) *PutBotAliasInput {
	s.Checksum = &v
	return s
}
682195
func (l LabelMap) checksumString(b *bytes.Buffer) {
	checksum := l.checksum()

	if checksum == 0 {
		// we don't write the checksum of the labels if the value of the checksum
		// is 0 (zero) to be backwards compatible with ringpop applications on
		// an older version. This only works if the newer version does not use
		// labels
		return
	}

	// write #labels<checksum> to the buffer which will be appended to the
	// checksum string for the node.
	b.WriteString("#labels")
	b.WriteString(strconv.Itoa(int(checksum)))
}
1143519
func (b UDP) SetChecksum(checksum uint16) {
	binary.BigEndian.PutUint16(b[udpChecksum:], checksum)
}
1045819
func (m Member) checksumString(b *bytes.Buffer) {
	b.WriteString(m.Address)
	b.WriteString(m.Status)
	b.WriteString(strconv.FormatInt(m.Incarnation, 10))
	m.Labels.checksumString(b)
}