MCPcopy Create free account
hub / github.com/cloudtty/cloudtty / truncateAndHashIfExceed

Function truncateAndHashIfExceed

pkg/controllers/utils.go:71–79  ·  view source on GitHub ↗
(input string)

Source from the content-addressed store, hash-verified

69}
70
71func truncateAndHashIfExceed(input string) string {
72 if len(input) <= LabelMaxLength {
73 return input
74 }
75 prefix := input[:LabelMaxLength-MD5Length]
76 suffix := input[LabelMaxLength-MD5Length:]
77 hash := md5.Sum([]byte(suffix))
78 return prefix + hex.EncodeToString(hash[:])
79}

Callers 2

AddLabelFunction · 0.85

Calls

no outgoing calls

Tested by 1