diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-08-13 15:17:29 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-08-13 16:42:58 +0200 |
commit | edebb1b96bb4f0008e1ef17845b988cc18899d16 (patch) | |
tree | d7f6a0c2ed27b9602d9da79e575b912016ba4caf /openpgp | |
parent | 6095dd58ea86629e4cce1f887a1ddbb407a3a800 (diff) |
openpgp: Add examples for Keygrip.
- See #474.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/crypto/keygrip.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/openpgp/src/crypto/keygrip.rs b/openpgp/src/crypto/keygrip.rs index 68401e53..3722ea0c 100644 --- a/openpgp/src/crypto/keygrip.rs +++ b/openpgp/src/crypto/keygrip.rs @@ -8,6 +8,35 @@ use crate::crypto::mpi::{MPI, PublicKey}; /// A proprietary, protocol agnostic identifier for public keys. /// /// This is defined and used by GnuPG. +/// +/// # Examples +/// +/// ``` +/// # fn main() -> sequoia_openpgp::Result<()> { +/// use sequoia_openpgp as openpgp; +/// use openpgp::crypto::Keygrip; +/// +/// let k: Keygrip = "DD143ABA8D1D7D09875D6209E01BCF020788FF77".parse()?; +/// assert_eq!(&k.to_string(), "DD143ABA8D1D7D09875D6209E01BCF020788FF77"); +/// +/// let cert: openpgp::Cert = // ... +/// # "-----BEGIN PGP PUBLIC KEY BLOCK----- +/// # +/// # xjMEWlNvABYJKwYBBAHaRw8BAQdA+EC2pvebpEbzPA9YplVgVXzkIG5eK+7wEAez +/// # lcBgLJrNMVRlc3R5IE1jVGVzdGZhY2UgKG15IG5ldyBrZXkpIDx0ZXN0eUBleGFt +/// # cGxlLm9yZz7CkAQTFggAOBYhBDnRAKtn1b2MBAECBfs3UfFYfa7xBQJaU28AAhsD +/// # BQsJCAcCBhUICQoLAgQWAgMBAh4BAheAAAoJEPs3UfFYfa7xJHQBAO4/GABMWUcJ +/// # 5D/DZ9b+6YiFnysSjCT/gILJgxMgl7uoAPwJherI1pAAh49RnPHBR1IkWDtwzX65 +/// # CJG8sDyO2FhzDs44BFpTbwASCisGAQQBl1UBBQEBB0B+A0GRHuBgdDX50T1nePjb +/// # mKQ5PeqXJbWEtVrUtVJaPwMBCAfCeAQYFggAIBYhBDnRAKtn1b2MBAECBfs3UfFY +/// # fa7xBQJaU28AAhsMAAoJEPs3UfFYfa7xzjIBANX2/FgDX3WkmvwpEHg/sn40zACM +/// # W2hrBY5x0sZ8H7JlAP47mCfCuRVBqyaePuzKbxLJeLe2BpDdc0n2izMVj8t9Cg== +/// # =QetZ +/// # -----END PGP PUBLIC KEY BLOCK-----".parse()?; +/// assert_eq!(&cert.primary_key().mpis().keygrip()?.to_string(), +/// "DD143ABA8D1D7D09875D6209E01BCF020788FF77"); +/// # Ok(()) } +/// ``` #[derive(Clone, PartialEq, Eq, Hash)] pub struct Keygrip([u8; 20]); |