MCPcopy Create free account
hub / github.com/encodeous/nylon / SealBundle

Function SealBundle

state/distribution.go:36–48  ·  view source on GitHub ↗
(data []byte, key []byte)

Source from the content-addressed store, hash-verified

34}
35
36func SealBundle(data []byte, key []byte) ([]byte, error) {
37 ahead, err := chacha20poly1305.NewX(key[:])
38 if err != nil {
39 return nil, err
40 }
41 nonce := make([]byte, chacha20poly1305.NonceSizeX)
42 _, err = rand.Read(nonce)
43 if err != nil {
44 return nil, err
45 }
46 cipherText := ahead.Seal(make([]byte, 0), nonce, data, make([]byte, 0))
47 return append(nonce, cipherText...), nil
48}
49
50func OpenBundle(data []byte, key []byte) ([]byte, error) {
51 if len(data) < chacha20poly1305.NonceSizeX {

Callers 3

writeRawBundleFunction · 0.92
BundleConfigFunction · 0.85
TestBundleInvalidData2Function · 0.85

Calls 1

ReadMethod · 0.65

Tested by 2

writeRawBundleFunction · 0.74
TestBundleInvalidData2Function · 0.68