[fix] debug prints have to go to stderr
This commit is contained in:
parent
7ffd6a4a11
commit
1ae56389fc
@ -35,7 +35,7 @@ pub fn encrypt<S: AsRef<str>>(
|
||||
ReadInfo::NormalChunk(n) => {
|
||||
assert_eq!(n, BUFSIZE);
|
||||
assert_eq!(buf.len(), BUFSIZE);
|
||||
println!("[encrypt]: read normal chunk");
|
||||
eprintln!("[encrypt]: read normal chunk");
|
||||
stream_encryptor.encrypt_next_in_place(&[], &mut buf)?;
|
||||
f_encrypted.write_all(&buf)?;
|
||||
// buf grows after encrypt_next_in_place because of tag that is added
|
||||
@ -43,14 +43,14 @@ pub fn encrypt<S: AsRef<str>>(
|
||||
buf.truncate(BUFSIZE);
|
||||
}
|
||||
ReadInfo::LastChunk(n) => {
|
||||
println!("[encrypt]: read last chunk");
|
||||
eprintln!("[encrypt]: read last chunk");
|
||||
buf.truncate(n);
|
||||
stream_encryptor.encrypt_last_in_place(&[], &mut buf)?;
|
||||
f_encrypted.write_all(&buf)?;
|
||||
break;
|
||||
}
|
||||
ReadInfo::EmptyChunk => {
|
||||
println!("[encrypt]: read empty chunk");
|
||||
eprintln!("[encrypt]: read empty chunk");
|
||||
panic!("[ERROR] Empty Chunk while reading");
|
||||
}
|
||||
}
|
||||
@ -81,20 +81,20 @@ pub fn decrypt<S: AsRef<str>>(
|
||||
match read_result {
|
||||
ReadInfo::NormalChunk(n) => {
|
||||
assert_eq!(n, BUFSIZE + 16);
|
||||
println!("[decrypt]: read normal chunk");
|
||||
eprintln!("[decrypt]: read normal chunk");
|
||||
stream_decryptor.decrypt_next_in_place(&[], &mut buf)?;
|
||||
f_plain.write_all(&buf)?;
|
||||
buf.resize(BUFSIZE + 16, 0);
|
||||
}
|
||||
ReadInfo::LastChunk(n) => {
|
||||
println!("[decrypt]: read last chunk");
|
||||
eprintln!("[decrypt]: read last chunk");
|
||||
buf.truncate(n);
|
||||
stream_decryptor.decrypt_last_in_place(&[], &mut buf)?;
|
||||
f_plain.write_all(&buf)?;
|
||||
break;
|
||||
}
|
||||
ReadInfo::EmptyChunk => {
|
||||
println!("[decrypt]: read empty chunk");
|
||||
eprintln!("[decrypt]: read empty chunk");
|
||||
panic!("Empty Chunk while reading");
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,6 @@ fn run(cli: Cli) -> Result<(), FcryError> {
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
if let Err(e) = run(cli) {
|
||||
println!("Error: {:?}", e);
|
||||
eprintln!("Error: {:?}", e);
|
||||
}
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ impl AheadReader {
|
||||
pub fn read_ahead(&mut self, userbuf: &mut [u8]) -> io::Result<ReadInfo> {
|
||||
// 1st read
|
||||
if self.bufsz == 0 {
|
||||
println!("[reader] first read");
|
||||
eprintln!("[reader] first read");
|
||||
return self.first_read(userbuf);
|
||||
}
|
||||
|
||||
println!("[reader] normal read");
|
||||
eprintln!("[reader] normal read");
|
||||
// normal read (not the 1st one)
|
||||
self.normal_read(userbuf)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user