github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/secret/token.go (about) 1 package secret 2 3 import ( 4 "bytes" 5 "fmt" 6 "hash/crc32" 7 ) 8 9 func Token(token string) string { 10 var mask bytes.Buffer 11 if len(token) > 16 { 12 mask.WriteString(token[:4]) 13 mask.WriteString("****") 14 mask.WriteString(token[len(token)-4:]) 15 } else { 16 mask.WriteString("****") 17 } 18 mask.WriteString(fmt.Sprintf("(CRC-32c: %08X)", crc32.Checksum([]byte(token), crc32.IEEETable))) 19 20 return mask.String() 21 }