package wire import ( "crypto/sha256" "fmt" "strconv" "strings" ) // QuotedData preserves lines inside a byte-counted block whose delimiter cannot // occur in the value. Source labels belong immediately before the returned text. func QuotedData(value string) string { if !strings.ContainsAny(value, "\n\r") { return strconv.Quote(value) } nonce := fmt.Sprintf("EQUIPO_DATA_%x", sha256.Sum256([]byte(value))) for strings.Contains(value, nonce) { nonce += "_" } return fmt.Sprintf("\n<%s bytes=%d>\n%s\n", nonce, len(value), value, nonce) }