mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix #556
This commit is contained in:
parent
19a0ffb673
commit
0993e9e146
@ -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"
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user