diff --git a/Cargo.toml b/Cargo.toml index 794c8de..7cabfaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cryptohelpers" -version = "1.8.1" +version = "1.8.2" license= "MIT" description = "Collection of helpers and simplifying functions for cryptography things" authors = ["Avril "] @@ -21,6 +21,7 @@ tokio = {version = "0.2", features=["io-util"], optional=true} serde_derive = {version = "1.0", optional = true} serde = {version = "1.0", optional = true} futures = {version = "0.3.8", optional=true} +base64 = "0.13.0" [features] default = ["full", "async", "serialise"] diff --git a/src/rsa/mod.rs b/src/rsa/mod.rs index e0e7d92..20b3ea2 100644 --- a/src/rsa/mod.rs +++ b/src/rsa/mod.rs @@ -1,5 +1,6 @@ //! RSA related thingies use super::*; +use std::fmt; pub use openssl; use consts::RSA_PADDING as PADDING; diff --git a/src/rsa/private.rs b/src/rsa/private.rs index 6b31bfc..aeeb4ae 100644 --- a/src/rsa/private.rs +++ b/src/rsa/private.rs @@ -59,6 +59,14 @@ pub struct RsaPrivateKey offset: PrivateOffsetGroup, } +impl fmt::Display for RsaPrivateKey +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result + { + write!(f, "{}", base64::encode(&self.data[..])) + } +} + impl RsaPrivateKey { /// Generate a new RSA private key diff --git a/src/rsa/public.rs b/src/rsa/public.rs index b332865..eccfaa7 100644 --- a/src/rsa/public.rs +++ b/src/rsa/public.rs @@ -55,6 +55,14 @@ pub struct RsaPublicKey offset: PublicOffsetGroup, } +impl fmt::Display for RsaPublicKey +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result + { + write!(f, "{}", base64::encode(&self.data[..])) + } +} + impl RsaPublicKey { /// Generate a new RSA public key (kinda useless, use `RsaPrivateKey::generate()`).