add README and LICENSE
This commit is contained in:
parent
763458aee2
commit
64d84f0fed
12 changed files with 663 additions and 0 deletions
|
|
@ -3,6 +3,13 @@ name = "jsonwebkey-convert"
|
|||
version = "0.1.0"
|
||||
authors = ["Okamura Yasunobu <okamura@informationsea.info>"]
|
||||
edition = "2018"
|
||||
license = "Apache-2.0"
|
||||
description = "Convert an RSA public key between Json Web Key and DER/PEM format."
|
||||
readme = "README.md"
|
||||
homepage = "https://github.com/informationsea/jsonwebkey-rs"
|
||||
repository = "https://github.com/informationsea/jsonwebkey-rs"
|
||||
keywords = ["jsonwebkey", "jsonwebtoken"]
|
||||
categories = ["authentication"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
|||
34
jsonwebkey-convert/README.md
Normal file
34
jsonwebkey-convert/README.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# jsonwebkey-convert
|
||||
Convert an RSA public key between Json Web Key and DER/PEM format.
|
||||
|
||||
## Convert PEM to JWK
|
||||
```rust
|
||||
use jsonwebkey_convert::*;
|
||||
|
||||
fn main() -> Result<(), JWKConvertError> {
|
||||
let pem_data = include_bytes!("../testfiles/test1.pem");
|
||||
let pem_rsa = load_pem(&pem_data[..])?;
|
||||
let jwk_data = RSAJWK {
|
||||
kid: Some("3f5fbba0-06c4-467c-8d5e-e935a71437b0".to_string()),
|
||||
jwk_use: Some("sig".to_string()),
|
||||
pubkey: pem_rsa
|
||||
};
|
||||
|
||||
let jwk_byte_vec = jwk_data.to_jwk()?;
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
## Convert JWK to PEM
|
||||
|
||||
```rust
|
||||
use jsonwebkey_convert::*;
|
||||
|
||||
fn main() -> Result<(), JWKConvertError> {
|
||||
let jwk_byte_vec = include_bytes!("../testfiles/test1.json");
|
||||
let jwk_data = load_jwk(&jwk_byte_vec[..])?;
|
||||
let rsa_pubkey = jwk_data.pubkey;
|
||||
let pem_string = rsa_pubkey.to_pem()?;
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue