I'm trying to write a simple function to transform ByteString
s with given ratio
. Quantity of xor
ed bits depends on the length
and ratio
.
rr <- randomRIO (0, BL.length bs)
let howMuch = floor $ (ratio args) * (fromIntegral rr)
transformIndexes <- replicateM howMuch $ randomRange (0, BL.length w)
What is the most efficient way to transform the ByteString
value bs
?
My first idea was to build another zero-filled ByteString
of the same length with xored bits on random positions and then use BL.zipWith xor
, but I'm afraid it's not the most efficient way because input bs
can be pretty big.