CH-J Toolsmanagementul serverului peste SSH
Meniu
Sursă publicată

CH-J Tools

Navighează directoarele și fișierele pentru o anumită versiune a aplicației.

Descarcă sursa ZIP
CH-J / Server Manager 1704 fișiere
0.1.2-beta Adăugat: · Construit:
hashing_util.rs Adăugat: Data neînregistrată 714 B · 27 linii
Cod Descarcă fișierul
1//! Streaming file digests used by downloads, transfers and backups.
3use sha2::{Digest, Sha256, Sha512};
4use std::io::Read;
5use std::path::Path;
7fn digest_file<D: Digest>(path: &Path) -> std::io::Result<String> {
8 let mut file = std::fs::File::open(path)?;
9 let mut hasher = D::new();
10 let mut buffer = vec![0u8; 256 * 1024];
11 loop {
12 let n = file.read(&mut buffer)?;
13 if n == 0 {
14 break;
15 }
16 hasher.update(&buffer[..n]);
17 }
18 Ok(hex::encode(hasher.finalize()))
21pub fn sha256_file(path: &Path) -> std::io::Result<String> {
22 digest_file::<Sha256>(path)
25pub fn sha512_file(path: &Path) -> std::io::Result<String> {
26 digest_file::<Sha512>(path)
SHA-25680fe297b376e748473810c912d3428c3360efd5309af30ebf341d723d3ca6f73

CH-J Proprietary Software License 1.14 · Sursa este furnizată în cadrul CH-J Proprietary Software License 1.14. Disponibilitatea sa nu modifică termenii licenţei sau nu acordă drepturi suplimentare.

Archive SHA-256ac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f
Fișiere