show fingerprint

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-04-19 14:39:22 +08:00
parent 08c4d2a1cf
commit 1100b2a465
53 changed files with 350 additions and 28 deletions

View File

@@ -840,3 +840,17 @@ pub fn is_peer_version_ge(v: &str) -> bool {
false
}
pub fn pk_to_fingerprint(pk: Vec<u8>) -> String {
let s: String = pk.iter().map(|u| format!("{:02x}", u)).collect();
s.chars()
.enumerate()
.map(|(i, c)| {
if i > 0 && i % 4 == 0 {
format!(" {}", c)
} else {
format!("{}", c)
}
})
.collect()
}