Registration endpoint fixing

This commit is contained in:
Imbus 2023-11-15 16:05:07 +01:00
parent f8dc9cfd29
commit dea4ac1fb3
8 changed files with 109 additions and 44 deletions

3
server/src/util/mod.rs Normal file
View file

@ -0,0 +1,3 @@
mod util;
pub use util::*;

19
server/src/util/util.rs Normal file
View 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);
}
}