1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-07-22 03:05:32 +02:00

feat: finish YouTube downloading; primitive "raw" archiving

This commit is contained in:
TheGeneralist 2025-10-15 00:29:08 +02:00
commit 01cc7826bf
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
9 changed files with 1059 additions and 0 deletions

17
src/hash.rs Normal file
View file

@ -0,0 +1,17 @@
use sha3::{Digest, Sha3_256};
use std::{fs::File, io::Read, path::Path};
use anyhow::Result;
pub fn hash_file(path: &Path) -> Result<String> {
let mut file = File::open(path)?;
let mut buf = Vec::new();
file.read_to_end(&mut buf)?;
Ok(hash(String::from_utf8_lossy(&buf).to_string()))
}
pub fn hash(path: String) -> String {
let mut hasher = Sha3_256::new();
hasher.update(path.as_bytes());
let result = hasher.finalize();
hex::encode(result)
}