Crates.io | jsonwebkey-convert |
lib.rs | jsonwebkey-convert |
version | 0.3.0 |
source | src |
created_at | 2020-07-25 04:09:34.912632 |
updated_at | 2021-01-09 15:57:13.056995 |
description | Convert an RSA public key between Json Web Key and DER/PEM format. |
homepage | https://github.com/informationsea/jsonwebkey-rs |
repository | https://github.com/informationsea/jsonwebkey-rs |
max_upload_size | |
id | 269414 |
size | 30,121 |
Convert an RSA public key between Json Web Key and DER/PEM format.
use jsonwebkey_convert::*;
use jsonwebkey_convert::der::FromPem;
fn main() -> Result<(), Error> {
let pem_data = include_str!("../testfiles/test1.pem");
let rsa_jwk = RSAPublicKey::from_pem(pem_data)?;
let jwk_byte_vec = serde_json::to_string(&rsa_jwk);
Ok(())
}
use jsonwebkey_convert::*;
use jsonwebkey_convert::der::ToPem;
fn main() -> Result<(), Error> {
let jwk_data = include_str!("../testfiles/test1.json");
let rsa_jwk: RSAPublicKey = jwk_data.parse()?;
let pem_data = rsa_jwk.to_pem()?;
Ok(())
}