jsonwebkey-convert

Crates.iojsonwebkey-convert
lib.rsjsonwebkey-convert
version0.3.0
sourcesrc
created_at2020-07-25 04:09:34.912632
updated_at2021-01-09 15:57:13.056995
descriptionConvert an RSA public key between Json Web Key and DER/PEM format.
homepagehttps://github.com/informationsea/jsonwebkey-rs
repositoryhttps://github.com/informationsea/jsonwebkey-rs
max_upload_size
id269414
size30,121
Yasunobu Okamura (informationsea)

documentation

README

jsonwebkey-convert

Convert an RSA public key between Json Web Key and DER/PEM format.

Convert PEM to JWK

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(())
}

Convert JWK to PEM

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(())
}
Commit count: 10

cargo fmt