This commit is contained in:
Acrimon 2020-05-13 01:08:33 +02:00
parent 19a0ffb673
commit 0993e9e146
No known key found for this signature in database
GPG Key ID: 79B55D369EAD2A06
2 changed files with 8 additions and 18 deletions

View File

@ -35,4 +35,4 @@ authc = { git = "https://gitlab.com/veloren/auth.git", rev = "65571ade0d954a0e0b
libsqlite3-sys = { version = "0.9.1", features = ["bundled"] }
diesel = { version = "1.4.3", features = ["sqlite"] }
diesel_migrations = "1.4.0"
dotenv = "0.15.0"
dotenv = "0.15.0"

View File

@ -5,24 +5,14 @@ use log::error;
use std::str::FromStr;
fn derive_uuid(username: &str) -> Uuid {
let mut state: [u8; 16] = [
52, 17, 19, 239, 52, 17, 19, 239, 52, 17, 19, 239, 52, 17, 19, 239,
];
for mix_byte_1 in username.as_bytes() {
for i in 0..16 {
let mix_byte_step: u8 = mix_byte_1
.wrapping_pow(239)
.wrapping_mul((i as u8).wrapping_pow(43));
let mix_byte_2 = state[(i + mix_byte_step as usize) % 16];
let rot_step: u8 = mix_byte_1
.wrapping_pow(29)
.wrapping_mul((i as u8).wrapping_pow(163));
state[i] = (state[i] ^ mix_byte_1)
.wrapping_mul(mix_byte_2)
.rotate_left(rot_step as u32);
}
let mut state = 144066263297769815596495629667062367629;
for byte in username.as_bytes() {
state ^= *byte as u128;
state = state.wrapping_mul(309485009821345068724781371);
}
Uuid::from_slice(&state).unwrap()
Uuid::from_slice(&state.to_be_bytes()).unwrap()
}
pub struct AuthProvider {