prs_lib/crypto/proto/
gpg.rs1const LONG_KEY_ID: usize = 16;
5
6#[derive(Clone)]
8pub struct Key {
9 pub fingerprint: String,
11
12 pub user_ids: Vec<String>,
14}
15
16impl Key {
17 pub fn fingerprint(&self, short: bool) -> String {
19 let fp = if short {
20 &self.fingerprint[self.fingerprint.len() - LONG_KEY_ID..]
21 } else {
22 &self.fingerprint
23 };
24
25 crate::crypto::util::normalize_fingerprint(fp)
26 }
27
28 pub fn display_user(&self) -> String {
30 self.user_ids.join("; ")
31 }
32
33 pub fn into_key(self) -> crate::crypto::Key {
35 crate::crypto::Key::Gpg(self)
36 }
37}
38
39impl PartialEq for Key {
40 fn eq(&self, other: &Self) -> bool {
41 self.fingerprint.trim().to_uppercase() == other.fingerprint.trim().to_uppercase()
42 }
43}