oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package wire
2
3import (
4 "crypto/sha256"
5 "fmt"
6 "strconv"
7 "strings"
8)
9
10// QuotedData preserves lines inside a byte-counted block whose delimiter cannot
11// occur in the value. Source labels belong immediately before the returned text.
12func QuotedData(value string) string {
13 if !strings.ContainsAny(value, "\n\r") {
14 return strconv.Quote(value)
15 }
16 nonce := fmt.Sprintf("EQUIPO_DATA_%x", sha256.Sum256([]byte(value)))
17 for strings.Contains(value, nonce) {
18 nonce += "_"
19 }
20 return fmt.Sprintf("\n<%s bytes=%d>\n%s\n</%s>", nonce, len(value), value, nonce)
21}
22