mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-04 18:40:47 +00:00
fix: possible crypto file write fixes
This commit is contained in:
parent
efac2e1965
commit
39aa1f0ad6
1 changed files with 9 additions and 3 deletions
|
|
@ -238,8 +238,8 @@ async fn age_decrypt_with_private_key<R: tokio::io::AsyncRead + Unpin>(
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut decrypt_writer = decryptor.decrypt_async(iter::once(
|
let mut decrypt_writer = decryptor.decrypt_async(iter::once(
|
||||||
&age::x25519::Identity::from_str(key).map_err(|e| ServiceError::AgeKeyError(e.to_string()))?
|
&age::x25519::Identity::from_str(key)
|
||||||
as &dyn age::Identity,
|
.map_err(|e| ServiceError::AgeKeyError(e.to_string()))? as &dyn age::Identity,
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
decrypt_writer.read_to_end(output_buffer).await?;
|
decrypt_writer.read_to_end(output_buffer).await?;
|
||||||
|
|
@ -289,12 +289,18 @@ pub async fn encrypt_file_with_recipients<P: AsRef<Path>>(
|
||||||
|
|
||||||
tokio::io::AsyncReadExt::read_to_end(&mut plain_file, &mut plain_file_contents).await?;
|
tokio::io::AsyncReadExt::read_to_end(&mut plain_file, &mut plain_file_contents).await?;
|
||||||
|
|
||||||
|
drop(plain_file);
|
||||||
|
|
||||||
age_encrypt_with_recipients(
|
age_encrypt_with_recipients(
|
||||||
plain_file_contents.as_slice(),
|
plain_file_contents.as_slice(),
|
||||||
&mut cipher_file,
|
&mut cipher_file,
|
||||||
&recipients,
|
&recipients,
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
|
|
||||||
|
tokio::io::AsyncWriteExt::shutdown(&mut cipher_file).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn decrypt_file_with_private_key<P: AsRef<Path>>(
|
pub async fn decrypt_file_with_private_key<P: AsRef<Path>>(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue