Hash the passwords client-side

This commit is contained in:
Mckol
2019-10-04 16:44:31 +00:00
parent 2b98b85020
commit 9aba318df2
3 changed files with 74 additions and 2 deletions

View File

@ -8,6 +8,7 @@ use crate::{window::Event, Direction, GlobalState, PlayState, PlayStateResult};
use client_init::{ClientInit, Error as InitError};
use common::{clock::Clock, comp};
use log::warn;
use sha2::{Digest, Sha512};
#[cfg(feature = "singleplayer")]
use start_singleplayer::StartSingleplayerState;
use std::time::Duration;
@ -108,7 +109,16 @@ impl PlayState for MainMenuState {
client_init = client_init.or(Some(ClientInit::new(
(server_address, DEFAULT_PORT, false),
player,
password,
{
// TODO: Switch to Argon2
let mut hasher = Sha512::new();
hasher.input(password.clone());
let mut out = String::new();
for i in hasher.result().iter() {
out.push_str(&format!("{:x}", i));
}
out
},
false,
)));
} else {