Registration endpoint fixing
This commit is contained in:
parent
f8dc9cfd29
commit
dea4ac1fb3
8 changed files with 109 additions and 44 deletions
3
server/src/util/mod.rs
Normal file
3
server/src/util/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
mod util;
|
||||
|
||||
pub use util::*;
|
19
server/src/util/util.rs
Normal file
19
server/src/util/util.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use rand::{Rng, RngCore};
|
||||
|
||||
// This will do for now
|
||||
pub fn hex_string(length: usize) -> String {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut bytes = vec![0u8; length];
|
||||
rng.fill(&mut bytes[..]);
|
||||
bytes.iter().map(|b| format!("{:X}", b)).collect::<String>()[..length].to_string()
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_random_hex_string() {
|
||||
let s = hex_string(16);
|
||||
assert_eq!(s.len(), 16);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue