Reduce identifier length to 12
The probability of a conflict due to birthday problem with a million of pastes is about 4.3e-9, which is acceptably low.
This commit is contained in:
parent
0175f9a593
commit
19fc79a1f6
|
@ -97,7 +97,7 @@ const CHARACTERS: &[u8] = b"23456789bcdfghjkmnpqrstvwxzBCDFGHJKLMNPQRSTVWX_-";
|
|||
|
||||
fn insert_paste(db: State<Database<PgConnection>>, Form(form): Form<PasteForm>) -> AsyncResponse {
|
||||
let mut rng = thread_rng();
|
||||
let identifier: String = (0..24)
|
||||
let identifier: String = (0..10)
|
||||
.map(|_| char::from(*CHARACTERS.choose(&mut rng).expect("a random character")))
|
||||
.collect();
|
||||
let delete_at = form.autodelete.map(|_| Utc::now() + Duration::hours(24));
|
||||
|
|
Loading…
Reference in New Issue
Block a user