MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / ToBytes

Method ToBytes

utils/binary/builder.go:36–46  ·  view source on GitHub ↗

ToBytes return data with tea encryption if key is set GC 安全, 返回的数据在 Builder 被销毁之后仍能被正确读取, 但是只能调用一次, 调用后 Builder 即失效

()

Source from the content-addressed store, hash-verified

34// GC 安全, 返回的数据在 Builder 被销毁之后仍能被正确读取,
35// 但是只能调用一次, 调用后 Builder 即失效
36func (b *Builder) ToBytes() (data []byte) {
37 b.p(func(ub *pbuf.UserBuffer[teacfg]) {
38 if ub.DAT.usetea {
39 data = ub.DAT.key.Encrypt(ub.Bytes())
40 return
41 }
42 data = make([]byte, ub.Len())
43 copy(data, ub.Bytes())
44 })
45 return
46}
47
48// Pack TLV with tea encryption if key is set
49//

Callers 15

MarshalMethod · 0.95
MarshalMethod · 0.95
MarshalMethod · 0.95
buildCode2dPacketMethod · 0.80
FetchQRCodeMethod · 0.80
GetQRCodeResultMethod · 0.80
QRCodeLoginMethod · 0.80
PackPacketMethod · 0.80
T106Function · 0.80
BuildKexExchangeRequestFunction · 0.80
TestBuilderFunction · 0.80

Calls 3

pMethod · 0.95
BytesMethod · 0.80
LenMethod · 0.80

Tested by 5

TestBuilderFunction · 0.64
TestBuilderTEAFunction · 0.64
BenchmarkNewBuilder128Function · 0.64
BenchmarkNewBuilder128_3Function · 0.64
BenchmarkNewBuilder128_5Function · 0.64