Skip to content

Commit

Permalink
bump rand and base64
Browse files Browse the repository at this point in the history
  • Loading branch information
FauxFaux committed Jul 26, 2019
1 parent 35fb36c commit f0efb28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -17,14 +17,14 @@ gzip = ["deflate"]
ssl = ["tiny_http/ssl"]

[dependencies]
base64 = "0.9.0"
base64 = "0.10"
brotli2 = { version = "0.3.2", optional = true }
chrono = "0.4.0"
filetime = "0.2.0"
deflate = { version = "0.7", optional = true, features = ["gzip"] }
multipart = { version = "0.16", default-features = false, features = ["server"] }
percent-encoding = "2"
rand = "0.5"
rand = "0.7"
serde = "1"
serde_derive = "1"
serde_json = "1"
Expand Down
7 changes: 6 additions & 1 deletion src/session.rs
Expand Up @@ -115,9 +115,14 @@ impl<'r> Session<'r> {
/// that could need to be escaped.
pub fn generate_session_id() -> String {
// 5e+114 possibilities is reasonable.
rand::OsRng::new().expect("Failed to initialize OsRng") // TODO: <- handle that?
rand::thread_rng()
.sample_iter(&Alphanumeric)
.filter(|&c| (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9'))
.take(64).collect::<String>()
}

#[test]
fn test_generate_session_id() {
assert!(generate_session_id().len() >= 32);
}

0 comments on commit f0efb28

Please sign in to comment.