I don't think anyone have implemented `xor` or `and` on them, but you can 
simply store the buffers as `seq[byte]`. But it's simple enough:
    
    
    proc `xor`(a, b: seq[byte]): seq[byte] =
      assert a.len == b.len
      result.setLen a.len
      for i in 0..a.high:
        result[i] = a[i] xor b[i]
    
    let
      b1 = @[234.byte, 69, 43, 20]
      b2 = @[0x1A.byte, 0x4F, 0xF5, 0xBD]
    
    echo b1 xor b2
    
    
    Run

The `readBytes` part is easy enough to do with 
`cast[seq[byte]](readFile("myfile.bin"))`, readFile returns a string which is 
basically just a `seq[char]` so that cast should be safe.

Reply via email to