Fix bench and docs
This commit is contained in:
parent
c244e835e0
commit
bdeefe5ed7
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "jsonwebtoken"
|
name = "jsonwebtoken"
|
||||||
version = "1.1.7"
|
version = "2.0.0"
|
||||||
authors = ["Vincent Prouillet <vincent@wearewizards.io>"]
|
authors = ["Vincent Prouillet <vincent@wearewizards.io>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
15
README.md
15
README.md
|
@ -26,7 +26,7 @@ header.
|
||||||
|
|
||||||
### Encoding
|
### Encoding
|
||||||
```rust
|
```rust
|
||||||
let token = encode(Header::default(), &my_claims, "secret".as_ref()).unwrap();
|
let token = encode(&Header::default(), &my_claims, "secret".as_ref()).unwrap();
|
||||||
```
|
```
|
||||||
In that example, `my_claims` is an instance of a Claims struct that derives `RustcEncodable` and `RustcDecodable`.
|
In that example, `my_claims` is an instance of a Claims struct that derives `RustcEncodable` and `RustcDecodable`.
|
||||||
The default algorithm is HS256.
|
The default algorithm is HS256.
|
||||||
|
@ -55,17 +55,10 @@ If you want to set the `kid` parameter for example:
|
||||||
let mut header = Header::default();
|
let mut header = Header::default();
|
||||||
header.kid = Some("blabla".to_owned());
|
header.kid = Some("blabla".to_owned());
|
||||||
header.alg = Algorithm::HS512;
|
header.alg = Algorithm::HS512;
|
||||||
let token = encode(header, &my_claims, "secret".as_ref()).unwrap();
|
let token = encode(&header, &my_claims, "secret".as_ref()).unwrap();
|
||||||
```
|
```
|
||||||
Look at `examples/custom_header.rs` for a full working example.
|
Look at `examples/custom_header.rs` for a full working example.
|
||||||
|
|
||||||
## Algorithms
|
## Algorithms
|
||||||
Right now, only HMAC SHA family is supported: HMAC SHA256, HMAC SHA384 and HMAC SHA512.
|
The HMAC SHA family is supported: HMAC SHA256, HMAC SHA384 and HMAC SHA512 as well as the RSA PKCS1: RSA_PKCS1_SHA256,
|
||||||
|
RSA_PKCS1_SHA384 and RSA_PKCS1_SHA512.
|
||||||
## Performance
|
|
||||||
On my thinkpad 440s for a 2 claims struct using HMAC SHA256:
|
|
||||||
|
|
||||||
```
|
|
||||||
test bench_decode ... bench: 4,947 ns/iter (+/- 611)
|
|
||||||
test bench_encode ... bench: 3,301 ns/iter (+/- 465)
|
|
||||||
```
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ fn bench_encode(b: &mut test::Bencher) {
|
||||||
company: "ACME".to_owned()
|
company: "ACME".to_owned()
|
||||||
};
|
};
|
||||||
|
|
||||||
b.iter(|| encode(Header::default(), &claim, "secret".as_ref()));
|
b.iter(|| encode(&Header::default(), &claim, "secret".as_ref()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
|
|
Loading…
Reference in New Issue