K2V #293

Merged
lx merged 68 commits from k2v into main 2022-05-10 11:16:58 +00:00
Showing only changes of commit fdbed3f1e8 - Show all commits

View file

@ -42,11 +42,12 @@ impl CausalContext {
bytes.extend(u64::to_be_bytes(i));
}
base64::encode(bytes)
base64::encode_config(bytes, base64::URL_SAFE_NO_PAD)
}
/// Parse from base64-encoded binary representation
pub fn parse(s: &str) -> Result<Self, Error> {
let bytes = base64::decode(s).ok_or_message("Invalid causality token (bad base64)")?;
let bytes = base64::decode_config(s, base64::URL_SAFE_NO_PAD)
.ok_or_message("Invalid causality token (bad base64)")?;
if bytes.len() % 16 != 8 || bytes.len() < 8 {
return Err(Error::Message(
"Invalid causality token (bad length)".into(),