Added `fmt::Display` impls for `RsaPublicKey` & `RsaPrivateKey`

Fortune for cryptohelpers's current commit: Future small blessing − 末小吉
tokio-1.0
Avril 3 years ago
parent f3f6252933
commit dfddaf0484
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -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 <flanchan@cumallover.me>"]
@ -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"]

@ -1,5 +1,6 @@
//! RSA related thingies
use super::*;
use std::fmt;
pub use openssl;
use consts::RSA_PADDING as PADDING;

@ -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

@ -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()`).

Loading…
Cancel
Save