Keats / jsonwebtoken

JWT lib in rust
MIT License
1.69k stars 271 forks source link

Add sign and verify on bytes #150

Closed clehner closed 3 years ago

clehner commented 4 years ago

Re: https://github.com/Keats/jsonwebtoken/pull/148#issuecomment-689074489

This adds sign_bytes and verify_bytes functions in crypto, corresponding to the existing public sign and verify functions but accepting a message as bytes instead of as a string. The existing sign and verify functions are changed to be implemented in terms of the new sign_bytes and verify_bytes functions.

I changed the internal sign/verify functions to use bytes instead of strings rather than adding new functions there too, since those functions are not exported.

Signing and verifying messages as bytes instead of (base64url-encoded) strings is needed for the Unencoded Payload Option (#149).

Keats commented 3 years ago

I think passing bytes everywhere is more flexible anyway and there is an upcoming major version so we can have breaking changes.