mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 10:26:29 +03:00
Update to base64 0.21
This commit is contained in:
10
src/tools.rs
10
src/tools.rs
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user