Trim whitespace from end of encryption key (#496)

This commit is contained in:
Martin Indra 2022-08-11 13:27:04 +02:00 committed by GitHub
parent 0c5e250800
commit 2abac5d853
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,7 +74,8 @@ pub fn encode_key(key: secretbox::Key) -> Result<String> {
}
pub fn decode_key(key: String) -> Result<secretbox::Key> {
let buf = base64::decode(key).wrap_err("encryption key is not a valid base64 encoding")?;
let buf =
base64::decode(key.trim_end()).wrap_err("encryption key is not a valid base64 encoding")?;
let buf: secretbox::Key = rmp_serde::from_slice(&buf)
.wrap_err("encryption key is not a valid message pack encoding")?;