memory-search: hex-encode cookie instead of alphanumeric mapping
This commit is contained in:
parent
0ea86b8d54
commit
300a09e04b
1 changed files with 2 additions and 3 deletions
|
|
@ -150,12 +150,11 @@ fn load_or_create_cookie(dir: &Path, session_id: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_cookie() -> String {
|
fn generate_cookie() -> String {
|
||||||
const ALPHA: &[u8] = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
let mut buf = [0u8; 12];
|
||||||
let mut buf = [0u8; 16];
|
|
||||||
fs::File::open("/dev/urandom")
|
fs::File::open("/dev/urandom")
|
||||||
.and_then(|mut f| io::Read::read_exact(&mut f, &mut buf))
|
.and_then(|mut f| io::Read::read_exact(&mut f, &mut buf))
|
||||||
.expect("failed to read urandom");
|
.expect("failed to read urandom");
|
||||||
buf.iter().map(|b| ALPHA[(*b as usize) % ALPHA.len()] as char).collect()
|
buf.iter().map(|b| format!("{:02x}", b)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_seen(dir: &Path, session_id: &str) -> HashSet<String> {
|
fn load_seen(dir: &Path, session_id: &str) -> HashSet<String> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue