MCPcopy Create free account
hub / github.com/chatmail/core / create_id

Function create_id

src/tools.rs:270–276  ·  view source on GitHub ↗

Generate an unique ID. The generated ID should be short but unique: - short, because it used in Chat-Group-ID headers and in QR codes - unique as two IDs generated on two devices should not be the same IDs generated by this function have 144 bits of entropy and are returned as 24 Base64 characters, each containing 6 bits of entropy. 144 is chosen because it is sufficiently secure (larger than AE

()

Source from the content-addressed store, hash-verified

268/// (larger than AES-128 keys used for message encryption)
269/// and divides both by 8 (byte size) and 6 (number of bits in a single Base64 character).
270pub(crate) fn create_id() -> String {
271 // Generate 144 random bits.
272 let mut arr = [0u8; 18];
273 rand::fill(&mut arr[..]);
274
275 base64::engine::general_purpose::URL_SAFE.encode(arr)
276}
277
278/// Generate a shared secret for a broadcast channel, consisting of 43 characters.
279///

Callers 8

get_securejoin_qrFunction · 0.85
create_groupFunction · 0.85
create_broadcastFunction · 0.85
lookup_or_newFunction · 0.85
test_create_idFunction · 0.85
prepareMethod · 0.85

Calls

no outgoing calls

Tested by 2

test_create_idFunction · 0.68