From 8caf218aed281ef8bbe82f8ab8a4b6a7b420c95e Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 4 Feb 2020 12:39:03 +0000 Subject: [PATCH] To and from b58 string on encryption public key --- common/crypto/src/encryption/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/crypto/src/encryption/mod.rs b/common/crypto/src/encryption/mod.rs index 650e221f0e..d3c8ba3d62 100644 --- a/common/crypto/src/encryption/mod.rs +++ b/common/crypto/src/encryption/mod.rs @@ -104,6 +104,14 @@ impl PublicKey { let key = MontgomeryPoint(bytes); Self(key) } + + pub fn to_base58_string(&self) -> String { + bs58::encode(&self.to_bytes()).into_string() + } + + pub fn from_base58_string(val: String) -> Self { + Self::from_bytes(&bs58::decode(&val).into_vec().unwrap()) + } } impl PemStorableKey for PublicKey {