[Add] Accepted Document Version
This commit is contained in:
parent
53a057c6e1
commit
0812d85e43
14 changed files with 231 additions and 72 deletions
|
|
@ -9,6 +9,7 @@ use x448::{PublicKey, Secret, SharedSecret};
|
|||
|
||||
/// Errors for crypto opertions
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub enum CryptoError {
|
||||
Base64Decode(base64::DecodeError),
|
||||
InvalidKey,
|
||||
|
|
@ -55,6 +56,7 @@ pub fn load_secret_key(base64_secret: &str) -> Option<Secret> {
|
|||
Secret::from_bytes(&bytes)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn derive_aes_key(shared: &SharedSecret) -> [u8; 32] {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(shared.as_bytes());
|
||||
|
|
@ -64,6 +66,7 @@ fn derive_aes_key(shared: &SharedSecret) -> [u8; 32] {
|
|||
key
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn encrypt(
|
||||
base64_secret: &str,
|
||||
base64_peer_pub: &str,
|
||||
|
|
@ -89,6 +92,7 @@ pub fn encrypt(
|
|||
Ok(STANDARD.encode(&out))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn decrypt(
|
||||
base64_secret: &str,
|
||||
base64_peer_pub: &str,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use x448::{PublicKey, Secret};
|
|||
|
||||
// --- Custom Errors ---
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub enum SecurePayloadError {
|
||||
InvalidBase64,
|
||||
InvalidHex,
|
||||
|
|
@ -19,6 +20,7 @@ pub enum SecurePayloadError {
|
|||
|
||||
// --- Data Format Enum ---
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub enum DataFormat {
|
||||
Raw,
|
||||
Base64,
|
||||
|
|
@ -42,6 +44,7 @@ impl Clone for SecurePayload {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl SecurePayload {
|
||||
/// Clear Constructor: Takes data in any format and the user's private key.
|
||||
pub fn new<S, T: AsRef<[u8]>>(
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ pub fn delete_file(path: &str, name: &str) -> bool {
|
|||
fs::remove_file(file).is_ok()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn delete_directory(path: &str) -> bool {
|
||||
let dir = Path::new(&get_directory()).join(path);
|
||||
delete_dir_recursive(&dir)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn delete_dir_recursive(directory: &Path) -> bool {
|
||||
if !directory.exists() {
|
||||
return false;
|
||||
|
|
@ -38,6 +40,7 @@ fn delete_dir_recursive(directory: &Path) -> bool {
|
|||
true
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn delete_user_directory(user_id: Uuid) {
|
||||
let user_dir = Path::new(&get_directory())
|
||||
.join("users")
|
||||
|
|
@ -187,6 +190,7 @@ pub fn get_directory() -> String {
|
|||
.to_string()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn used_space() -> u64 {
|
||||
get_directory_size(&PathBuf::from(get_directory()))
|
||||
}
|
||||
|
|
@ -208,6 +212,7 @@ pub fn get_directory_size(directory: &Path) -> u64 {
|
|||
size
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_designed_storage(user_id: Uuid) -> String {
|
||||
let user_dir = Path::new(&get_directory())
|
||||
.join("users")
|
||||
|
|
@ -215,6 +220,7 @@ pub fn get_designed_storage(user_id: Uuid) -> String {
|
|||
design_byte(get_directory_size(&user_dir))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn design_byte(bytes: u64) -> String {
|
||||
let mut hr_size = format!("{:.2}B", bytes as f64);
|
||||
let k = bytes as f64 / 1024.0;
|
||||
|
|
@ -234,6 +240,7 @@ pub fn design_byte(bytes: u64) -> String {
|
|||
hr_size
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_used_ram() -> String {
|
||||
let mut sys = System::new_all();
|
||||
sys.refresh_all();
|
||||
|
|
@ -243,6 +250,7 @@ pub fn get_used_ram() -> String {
|
|||
}
|
||||
|
||||
// Helper to download the zip file content to a file on disk
|
||||
#[allow(dead_code)]
|
||||
async fn download_zip(url: &str, as_name: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let response = reqwest::get(url).await?;
|
||||
|
||||
|
|
@ -258,6 +266,7 @@ async fn download_zip(url: &str, as_name: &Path) -> Result<(), Box<dyn std::erro
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code, deprecated)]
|
||||
fn extract_zip_contents_to_folder(
|
||||
zip_path: &Path,
|
||||
target_dir: &Path,
|
||||
|
|
@ -334,6 +343,7 @@ fn extract_zip_contents_to_folder(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn download_and_extract_zip(url: &str, as_name: &str) {
|
||||
let base_dir = PathBuf::from(get_directory());
|
||||
let zip_filename = format!("{}.zip", Uuid::new_v4()); // Use a unique name for the downloaded ZIP file
|
||||
|
|
|
|||
Loading…
Reference in a new issue