mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-18 05:51:17 +00:00
feat: direct writing to file
This commit is contained in:
parent
1f0b9c94db
commit
18c6b33f17
2 changed files with 3 additions and 4 deletions
|
|
@ -13,6 +13,7 @@ jsonwebtoken = "8.1.1"
|
|||
dotenv = "0.15.0"
|
||||
tokio = "1.21.2"
|
||||
futures = "0.3.25"
|
||||
async-compat = "0.2.1"
|
||||
|
||||
# crypto
|
||||
argon2 = { version = "0.4", features = ["std"] }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use argon2::{
|
||||
Argon2, PasswordHasher as ArgonPasswordHasher, PasswordVerifier as ArgonPasswordVerifier,
|
||||
};
|
||||
use async_compat::CompatExt;
|
||||
use secrecy::ExposeSecret;
|
||||
use futures::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use rand::Rng;
|
||||
|
|
@ -195,8 +196,7 @@ pub async fn encrypt_file_with_recipients(
|
|||
|
||||
tokio::io::AsyncReadExt::read_to_end(&mut plain_file, &mut plain_file_contents).await?;
|
||||
|
||||
let mut encrypt_buffer = Vec::new();
|
||||
let mut encrypt_writer = encryptor.wrap_async_output(&mut encrypt_buffer).await?;
|
||||
let mut encrypt_writer = encryptor.wrap_async_output(cipher_file.compat_mut()).await?;
|
||||
|
||||
encrypt_writer.write_all(&plain_file_contents).await?;
|
||||
|
||||
|
|
@ -204,8 +204,6 @@ pub async fn encrypt_file_with_recipients(
|
|||
|
||||
encrypt_writer.close().await?;
|
||||
|
||||
tokio::io::AsyncWriteExt::write_all(&mut cipher_file, &encrypt_buffer).await?;
|
||||
|
||||
return Ok(());
|
||||
} else {
|
||||
// TODO: Error handling
|
||||
|
|
|
|||
Loading…
Reference in a new issue