Print the public key in PKey example

This commit is contained in:
Ansley Peduru 2018-01-23 22:43:53 -05:00
parent b9eace6569
commit 6552a9cbfd
1 changed files with 5 additions and 1 deletions

View File

@ -24,7 +24,7 @@
//! //!
//! # Example //! # Example
//! //!
//! Generate a 2048-bit RSA public/private key pair. //! Generate a 2048-bit RSA public/private key pair and print the public key.
//! //!
//! ```rust //! ```rust
//! //!
@ -32,10 +32,14 @@
//! //!
//! use openssl::rsa::Rsa; //! use openssl::rsa::Rsa;
//! use openssl::pkey::PKey; //! use openssl::pkey::PKey;
//! use std::str;
//! //!
//! fn main() { //! fn main() {
//! let rsa = Rsa::generate(2048).unwrap(); //! let rsa = Rsa::generate(2048).unwrap();
//! let pkey = PKey::from_rsa(rsa).unwrap(); //! let pkey = PKey::from_rsa(rsa).unwrap();
//!
//! let pub_key: Vec<u8> = pkey.public_key_to_pem().unwrap();
//! println!("{:?}", str::from_utf8(pub_key.as_slice()).unwrap());
//! } //! }
//! ``` //! ```