Skip to content

Commit

Permalink
refactor: use crc32 hash for secret description
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Dec 29, 2024
1 parent 7df03a7 commit a5ef9c1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/config/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,17 +899,28 @@ impl PingapConf {
});
}
for (name, data) in value.certificates.iter() {
let mut clone_data = data.clone();
if let Some(cert) = &clone_data.tls_cert {
clone_data.tls_cert = Some(format!("crc32:{:X}", crc32fast::hash(cert.as_bytes())));
}
if let Some(key) = &clone_data.tls_key {
clone_data.tls_key = Some(format!("crc32:{:X}", crc32fast::hash(key.as_bytes())));
}
descriptions.push(Description {
category: CATEGORY_CERTIFICATE.to_string(),
name: format!("certificate:{name}"),
data: toml::to_string_pretty(data).unwrap_or_default(),
data: toml::to_string_pretty(&clone_data).unwrap_or_default(),
});
}
for (name, data) in value.storages.iter() {
let mut clone_data = data.clone();
if let Some(secret) = &clone_data.secret {
clone_data.secret = Some(format!("crc32:{:X}", crc32fast::hash(secret.as_bytes())));
}
descriptions.push(Description {
category: CATEGORY_STORAGE.to_string(),
name: format!("storage:{name}"),
data: toml::to_string_pretty(data).unwrap_or_default(),
data: toml::to_string_pretty(&clone_data).unwrap_or_default(),
});
}
value.servers = HashMap::new();
Expand Down

0 comments on commit a5ef9c1

Please sign in to comment.