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
()
| 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). |
| 270 | pub(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 | /// |
no outgoing calls