CH-J Toolsserverio valdymas per SSH
Meniu
Paskelbtas šaltinis

CH-J Tools

Naršyti aplankus ir failus konkrečiai programai išleisti.

Atsisiųsti šaltinį ZIP
CH-J / Server Manager 1704 failai
0.1.2-beta Pridėta: · Pastatytas:
hashing_util.rs Pridėta: Data neregistruota 714 B · 27 eilutės
Kodas Atsiųsti failą
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 · Šaltinis pateiktas pagal CH-J Proprietary Software License 1.14. Jo prieinamumas nekeičia licencijos sąlygų ir nesuteikia papildomų teisių.

Archyvas SHA-256ac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f
Failai