Files
Aether/crates/aether-runtime/src/redaction.rs
fawney19 763ff03a7b refactor: 拆分 gateway 单体为独立 crate,新增 systemd 部署方案
将 gateway 内部的 model-fetch、provider-transport、scheduler-core、
usage-runtime、video-tasks-core 模块提取为独立 crate;重构 gateway
内部模块结构(state/router/cache/data/query 等);移除大量遗留模块
文件;新增 systemd 二进制部署骨架及相关文档;更新前端 usage 相关
API 和组件。
2026-04-05 20:23:16 +08:00

37 lines
932 B
Rust

use std::fmt::Write as _;
use sha2::{Digest, Sha256};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TextPayloadSummary {
pub bytes: usize,
pub sha256: String,
}
pub fn summarize_text_payload(text: &str) -> TextPayloadSummary {
let digest = Sha256::digest(text.as_bytes());
let mut sha256 = String::with_capacity(digest.len() * 2);
for byte in digest {
write!(&mut sha256, "{byte:02x}").expect("writing to string should not fail");
}
TextPayloadSummary {
bytes: text.len(),
sha256,
}
}
#[cfg(test)]
mod tests {
use super::summarize_text_payload;
#[test]
fn summarizes_text_payload_without_exposing_content() {
let summary = summarize_text_payload("secret-body");
assert_eq!(summary.bytes, 11);
assert_eq!(
summary.sha256,
"7c3029502007b2beae470d090221f0a8f7708be361be4662f4b649426e5767b3"
);
}
}