MCPcopy Create free account
hub / github.com/ethstorage/es-node / MaskDataInPlace

Function MaskDataInPlace

ethstorage/data_file.go:58–66  ·  view source on GitHub ↗

Mask the data in place. Padding zeros to userData if the len of userData is smaller than that of maskData.

(maskData []byte, userData []byte)

Source from the content-addressed store, hash-verified

56
57// Mask the data in place. Padding zeros to userData if the len of userData is smaller than that of maskData.
58func MaskDataInPlace(maskData []byte, userData []byte) []byte {
59 if len(userData) > len(maskData) {
60 panic("user data can not be larger than mask data")
61 }
62 for i := 0; i < len(userData); i++ {
63 maskData[i] = maskData[i] ^ userData[i]
64 }
65 return maskData
66}
67
68// Unmask the data in place
69func UnmaskDataInPlace(userData []byte, maskData []byte) []byte {

Callers 1

encodeChunkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected