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:
Konrad Borowski 2019-03-08 09:02:11 +01:00
parent 0175f9a593
commit 19fc79a1f6

View File

@ -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));