// SetChecksum sets the Checksum field's value.
3166
func (s *ArchiveCreationOutput) SetChecksum(v string) *ArchiveCreationOutput {
	s.Checksum = &v
	return s
}
916205
func (s *UploadMultipartPartInput) SetChecksum(v string) *UploadMultipartPartInput {
	s.Checksum = &v
	return s
}
330863
func xorChecksum(s string) string {
	var checksum uint8
	for i := 0; i < len(s); i++ {
		checksum ^= s[i]
	}
	return fmt.Sprintf("%02X", checksum)
}
665881
func (s *GetBotOutput) SetChecksum(v string) *GetBotOutput {
	s.Checksum = &v
	return s
}
1226739
func (e *ErasureInfo) AddChecksumInfo(ckSumInfo ChecksumInfo) {
	for i, sum := range e.Checksums {
		if sum.Name == ckSumInfo.Name {
			e.Checksums[i] = ckSumInfo
			return
		}
	}
	e.Checksums = append(e.Checksums, ckSumInfo)
}
866157
func (s *TrustedAdvisorCheckSummary) SetCheckId(v string) *TrustedAdvisorCheckSummary {
	s.CheckId = &v
	return s
}
467079
func RemoveChecksum(input Trytes) (Trytes, error) {
	if !guards.IsTrytesOfExactLength(input, HashTrytesSize) &&
		!guards.IsTrytesOfExactLength(input, AddressWithChecksumTrytesSize) {
		return "", ErrInvalidAddress
	}
	return input[:HashTrytesSize], nil
}
130343
func (s *TrustedAdvisorCheckResult) SetCheckId(v string) *TrustedAdvisorCheckResult {
	s.CheckId = &v
	return s
}
1114890
func (c *fileChecksum) checksum(source string) error {
	f, err := os.Open(source)
	if err != nil {
		return fmt.Errorf("Failed to open file for checksum: %s", err)
	}
	defer f.Close()

	c.Hash.Reset()
	if _, err := io.Copy(c.Hash, f); err != nil {
		return fmt.Errorf("Failed to hash: %s", err)
	}

	if actual := c.Hash.Sum(nil); !bytes.Equal(actual, c.Value) {
		return &ChecksumError{
			Hash:     c.Hash,
			Actual:   actual,
			Expected: c.Value,
			File:     source,
		}
	}

	return nil
}
127959
func addChecksum(data []byte) []byte {
	// Get first byte of sha256
	hash := computeChecksum(data)
	firstChecksumByte := hash[0]

	// len() is in bytes so we divide by 4
	checksumBitLength := uint(len(data) / 4)

	// For each bit of check sum we want we shift the data one the left
	// and then set the (new) right most bit equal to checksum bit at that index
	// staring from the left
	dataBigInt := new(big.Int).SetBytes(data)
	for i := uint(0); i < checksumBitLength; i++ {
		// Bitshift 1 left
		dataBigInt.Mul(dataBigInt, bigTwo)

		// Set rightmost bit if leftmost checksum bit is set
		if uint8(firstChecksumByte&(1<<(7-i))) > 0 {
			dataBigInt.Or(dataBigInt, bigOne)
		}
	}

	return dataBigInt.Bytes()
}
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
}
1341678
func checksum(path string) (string, error) {
	f, err := os.Open(path)
	if err != nil {
		log.Debug(err)
		return "", errors.New("cannot open file")
	}
	defer f.Close()

	h := md5.New()
	if _, err := io.Copy(h, f); err != nil {
		log.Debug(err)
		return "", fmt.Errorf("failed to compute MD5 sum of %s", path)
	}

	return hex.EncodeToString(h.Sum(nil)), nil
}
256412
func (s *PutBotInput) SetChecksum(v string) *PutBotInput {
	s.Checksum = &v
	return s
}
550817
func (opts *ReadOptions) SetVerifyChecksums(value bool) {
	C.rocksdb_readoptions_set_verify_checksums(opts.c, boolToChar(value))
}
1068352
func (a Artifact) Checksum(algorithm string) (string, error) {
	log.Debugf("calculating checksum for %s", a.Path)
	file, err := os.Open(a.Path)
	if err != nil {
		return "", errors.Wrap(err, "failed to checksum")
	}
	defer file.Close() // nolint: errcheck
	var h hash.Hash
	switch algorithm {
	case "crc32":
		h = crc32.NewIEEE()
	case "md5":
		h = md5.New()
	case "sha224":
		h = sha256.New224()
	case "sha384":
		h = sha512.New384()
	case "sha256":
		h = sha256.New()
	case "sha1":
		h = sha1.New()
	case "sha512":
		h = sha512.New()
	default:
		return "", fmt.Errorf("invalid algorith: %s", algorithm)
	}
	_, err = io.Copy(h, file)
	if err != nil {
		return "", errors.Wrap(err, "failed to checksum")
	}
	return hex.EncodeToString(h.Sum(nil)), nil
}
989399
func DirChecksum(expected map[string]string, dir string) *Result {
	actual, err := checkDir(dir, false)
	if err != nil {
		return &Result{err: err.Error()}
	}
	return Interface(expected, actual)
}
142555
func (t *TLSConfig) SetChecksum() error {
	newCertChecksum, err := createChecksumOfFiles(t.CAFile, t.CertFile, t.KeyFile)
	if err != nil {
		return err
	}

	t.Checksum = newCertChecksum
	return nil
}