Update to base64 0.21

This commit is contained in:
link2xt
2023-01-31 19:24:20 +00:00
parent 1e71d8dcc8
commit b62c61329a
8 changed files with 19 additions and 15 deletions

View File

@@ -12,6 +12,7 @@ use std::str::from_utf8;
use std::time::{Duration, SystemTime};
use anyhow::{bail, Context as _, Result};
use base64::Engine as _;
use chrono::{Local, TimeZone};
use futures::{StreamExt, TryStreamExt};
use mailparse::dateparse;
@@ -276,12 +277,6 @@ async fn maybe_warn_on_outdated(context: &Context, now: i64, approx_compile_time
/// - for INCOMING messages, the ID is taken from the Chat-Group-ID-header or from the Message-ID in the In-Reply-To: or References:-Header
/// - the group-id should be a string with the characters [a-zA-Z0-9\-_]
pub(crate) fn create_id() -> String {
const URL_SAFE_ENGINE: base64::engine::fast_portable::FastPortable =
base64::engine::fast_portable::FastPortable::from(
&base64::alphabet::URL_SAFE,
base64::engine::fast_portable::NO_PAD,
);
// ThreadRng implements CryptoRng trait and is supposed to be cryptographically secure.
let mut rng = thread_rng();
@@ -290,7 +285,8 @@ pub(crate) fn create_id() -> String {
rng.fill(&mut arr[..]);
// Take 11 base64 characters containing 66 random bits.
base64::encode_engine(arr, &URL_SAFE_ENGINE)
base64::engine::general_purpose::URL_SAFE
.encode(arr)
.chars()
.take(11)
.collect()