CH-J Toolsgestione server su SSH
Menu
Sorgente pubblicata

CH-J Tools

Sfoglia directory e file per una specifica release di applicazioni.

Scarica sorgente ZIP
CH-J / Server Manager 1704 file
0.1.2-beta Aggiunto: · Costruito:
hashing_util.rs Aggiunto: Data non registrata 714 B · 27 righe
Codice Scarica file
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 · La sorgente è fornita sotto CH-J Proprietary Software License 1.14. La sua disponibilità non modifica i termini di licenza o concede diritti aggiuntivi.

Archivio SHA-256ac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f
File