CH-J Tools透過 SSH 管理伺服器
選單
已發布的原始碼

CH-J Tools

瀏覽特定應用程式版本的目錄與檔案。

下載原始碼 ZIP
CH-J / Server Manager 1704 個檔案
0.1.2-beta 新增時間: · 建置時間:
hashing_util.rs 新增時間: 未記錄日期 714 B · 27 行
程式碼 下載檔案
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 · 原始碼依 CH-J Proprietary Software License 1.14 提供。公開原始碼不會改變授權條款,也不會授予額外的權利。

壓縮檔 SHA-256ac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f
檔案