// checksumShortName returns the checksum for the shortname that is used
// for the long name entries.
545390
func checksumShortName(name string) uint8 {
	var sum uint8 = name[0]
	for i := uint8(1); i < 11; i++ {
		sum = name[i] + (((sum & 1) << 7) + ((sum & 0xFE) >> 1))
	}

	return sum
}
146128
func (s *CreateMicrosoftADInput) SetShortName(v string) *CreateMicrosoftADInput {
	s.ShortName = &v
	return s
}
103569
func (u *Update) VerifyChecksum(checksum []byte) *Update {
	u.Checksum = checksum
	return u
}
694848
func EncodeChecksum(checksum string) string {
	return fmt.Sprintf("%s=%s", DigestSHA256, base64.StdEncoding.EncodeToString([]byte(checksum)))
}
1192447
func SafeFileName(str string) string {
	name := strings.ToLower(str)
	name = path.Clean(path.Base(name))
	name = strings.Trim(name, " ")
	separators, err := regexp.Compile(`[ &_=+:]`)
	if err == nil {
		name = separators.ReplaceAllString(name, "-")
	}
	legal, err := regexp.Compile(`[^[:alnum:]-.]`)
	if err == nil {
		name = legal.ReplaceAllString(name, "")
	}
	for strings.Contains(name, "--") {
		name = strings.Replace(name, "--", "-", -1)
	}
	return name
}
99783
func checksum(data []byte) ([]byte, error) {
	hash, err := hashDoubleSha256(data)
	if err != nil {
		return nil, err
	}

	return hash[:4], nil
}
897803
func (c *Command) MarkFlagFilename(name string, extensions ...string) error {
	return MarkFlagFilename(c.Flags(), name, extensions...)
}
281562
func ShortName(n string) Field {
	return func(p *Packet) error {
		return p.append(shortName, []byte(n))
	}
}
965812
func checksum(ctx context.Context, filename string, h hash.Hash) (b []byte, err error) {
	var f *os.File
	f, err = os.Open(filename)
	if err != nil {
		return
	}
	defer func() {
		err = f.Close()
	}()

	t := newTransfer(ctx, nil, h, f, nil)
	if _, err = t.copy(); err != nil {
		return
	}

	b = h.Sum(nil)
	return
}
1281162
func (s *Layer) SetShortname(v string) *Layer {
	s.Shortname = &v
	return s
}
153851
func IsValidName(name string) error {
	if len(name) == 0 {
		return errors.Errorf("cannot be empty")
	}
	if len(name) > maxNameLen {
		return errors.Errorf("too long: %v has length %d, max allowed is %d", name, len(name), maxNameLen)
	}
	if strings.IndexFunc(name[:1], isInvalidFirstRune) != -1 {
		return errors.Errorf("name must start with [a-z_]. Actual='%s'", name)
	}
	if strings.IndexFunc(name[1:], isInvalidOtherRune) != -1 {
		return errors.Errorf("name must contain only [a-z0-9_], Actual='%s'", name)
	}
	return nil
}
863538
func IsValidName(name string) bool {
	// doesn't contain the prefix
	if !strings.HasPrefix(name, Prefix) {
		return false
	}
	// it's required to have at least the following chars `x-x-0`
	suffix := name[len(Prefix):]
	if len(suffix) < 5 {
		return false
	}
	// lastly check the last part is a number
	lastHyphen := strings.LastIndex(suffix, "-")
	revision := suffix[lastHyphen+1:]
	_, err := strconv.Atoi(revision)
	return err == nil
}
330863
func xorChecksum(s string) string {
	var checksum uint8
	for i := 0; i < len(s); i++ {
		checksum ^= s[i]
	}
	return fmt.Sprintf("%02X", checksum)
}
192899
func (s *App) SetShortname(v string) *App {
	s.Shortname = &v
	return s
}
322551
func (s *CreateAppInput) SetShortname(v string) *CreateAppInput {
	s.Shortname = &v
	return s
}
165142
func (b UDP) CalculateChecksum(partialChecksum uint16, totalLen uint16) uint16 {
	// Add the length portion of the checksum to the pseudo-checksum.
	tmp := make([]byte, 2)
	binary.BigEndian.PutUint16(tmp, totalLen)
	checksum := Checksum(tmp, partialChecksum)

	// Calculate the rest of the checksum.
	return Checksum(b[:UDPMinimumSize], checksum)
}
303970
func (a *AdvPacket) AppendName(n string) *AdvPacket {
	typ := byte(typeCompleteName)
	if len(a.b)+2+len(n) > MaxEIRPacketLength {
		typ = byte(typeShortName)
	}
	return a.AppendField(typ, []byte(n))
}