Add padding to the base64 string

This commit is contained in:
traxys 2023-07-29 10:59:17 +02:00
parent b6f809a92b
commit d55a6c181b

View file

@ -33,7 +33,7 @@ impl std::fmt::Debug for Base64 {
write!( write!(
f, f,
r#"b64"{}""#, r#"b64"{}""#,
&general_purpose::STANDARD_NO_PAD.encode(self.0.to_bytes()) &general_purpose::STANDARD.encode(self.0.to_bytes())
) )
} }
} }
@ -43,7 +43,7 @@ impl Serialize for Base64 {
where where
S: Serializer, S: Serializer,
{ {
ser.serialize_str(&general_purpose::STANDARD_NO_PAD.encode(self.0.to_bytes())) ser.serialize_str(&general_purpose::STANDARD.encode(self.0.to_bytes()))
} }
} }
@ -66,7 +66,7 @@ impl<'de> Deserialize<'de> for Base64 {
where where
E: serde::de::Error, E: serde::de::Error,
{ {
general_purpose::STANDARD_NO_PAD general_purpose::STANDARD
.decode(v) .decode(v)
.map_err(E::custom) .map_err(E::custom)
.map(|b| HS256Key::from_bytes(&b)) .map(|b| HS256Key::from_bytes(&b))