Struct jsonwebtoken::DecodingKey
source · pub struct DecodingKey { /* private fields */ }
Expand description
All the different kind of keys we can use to decode a JWT. This key can be re-used so make sure you only initialize it once if you can for better performance.
Implementations§
source§impl DecodingKey
impl DecodingKey
sourcepub fn from_secret(secret: &[u8]) -> Self
pub fn from_secret(secret: &[u8]) -> Self
If you’re using HMAC, use this.
sourcepub fn from_base64_secret(secret: &str) -> Result<Self>
pub fn from_base64_secret(secret: &str) -> Result<Self>
If you’re using HMAC with a base64 encoded secret, use this.
sourcepub fn from_rsa_pem(key: &[u8]) -> Result<Self>
pub fn from_rsa_pem(key: &[u8]) -> Result<Self>
If you are loading a public RSA key in a PEM format, use this.
Only exists if the feature use_pem
is enabled.
sourcepub fn from_rsa_components(modulus: &str, exponent: &str) -> Result<Self>
pub fn from_rsa_components(modulus: &str, exponent: &str) -> Result<Self>
If you have (n, e) RSA public key components as strings, use this.
sourcepub fn from_rsa_raw_components(modulus: &[u8], exponent: &[u8]) -> Self
pub fn from_rsa_raw_components(modulus: &[u8], exponent: &[u8]) -> Self
If you have (n, e) RSA public key components already decoded, use this.
sourcepub fn from_ec_pem(key: &[u8]) -> Result<Self>
pub fn from_ec_pem(key: &[u8]) -> Result<Self>
If you have a ECDSA public key in PEM format, use this.
Only exists if the feature use_pem
is enabled.
sourcepub fn from_ec_components(x: &str, y: &str) -> Result<Self>
pub fn from_ec_components(x: &str, y: &str) -> Result<Self>
If you have (x,y) ECDSA key components
sourcepub fn from_ed_pem(key: &[u8]) -> Result<Self>
pub fn from_ed_pem(key: &[u8]) -> Result<Self>
If you have a EdDSA public key in PEM format, use this.
Only exists if the feature use_pem
is enabled.
sourcepub fn from_rsa_der(der: &[u8]) -> Self
pub fn from_rsa_der(der: &[u8]) -> Self
If you know what you’re doing and have a RSA DER encoded public key, use this.
sourcepub fn from_ec_der(der: &[u8]) -> Self
pub fn from_ec_der(der: &[u8]) -> Self
If you know what you’re doing and have a RSA EC encoded public key, use this.
sourcepub fn from_ed_der(der: &[u8]) -> Self
pub fn from_ed_der(der: &[u8]) -> Self
If you know what you’re doing and have a Ed DER encoded public key, use this.
sourcepub fn from_ed_components(x: &str) -> Result<Self>
pub fn from_ed_components(x: &str) -> Result<Self>
From x part (base64 encoded) of the JWK encoding
Trait Implementations§
source§impl Clone for DecodingKey
impl Clone for DecodingKey
source§fn clone(&self) -> DecodingKey
fn clone(&self) -> DecodingKey
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more