frostfs-api-go-pogpp/hash/salt.go
Evgeniy Kulikov 1cf33e5ffd
initial
2019-11-18 16:34:06 +03:00

17 lines
307 B
Go

package hash
// SaltXOR xors bits of data with salt
// repeating salt if necessary.
func SaltXOR(data, salt []byte) (result []byte) {
result = make([]byte, len(data))
ls := len(salt)
if ls == 0 {
copy(result, data)
return
}
for i := range result {
result[i] = data[i] ^ salt[i%ls]
}
return
}