-
-
Save archshift/8e0138bea4562af4524b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try!(file.seek(SeekFrom::Start(file_pos)));; | |
try!(pad.seek(SeekFrom::Start(pad_pos))); | |
let mut file_reader = BufStream::with_capacities(BUF_SIZE, BUF_SIZE, file).take(size); | |
let mut pad_reader = BufStream::with_capacities(BUF_SIZE, BUF_SIZE, pad).take(size); | |
loop { | |
let mut read_buf_size; | |
let mut read_pad_size; | |
{ | |
let buf = try!(file_reader.fill_buf()); | |
let pad = try!(pad_reader.fill_buf()); | |
if buf.is_empty() || pad.is_empty() { | |
break; | |
} | |
read_buf_size = buf.len(); | |
read_pad_size = pad.len(); | |
try!(file.write_all(&xor(buf, pad))); | |
} | |
file_reader.consume(read_buf_size); | |
pad_reader.consume(read_pad_size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment