manager 0.1.0

Artifice Management crate
use crypto::digest::Digest;
use crypto::sha2::Sha256;

use networking::random_string;

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Hash)]
pub struct RemoteUser {
    username: String,
    user_id: String,
    userpairkey: String,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct ArtificeUser {
    username: String,
    user_id: String,
    password: String,
}
/// represents a login user
impl ArtificeUser {
    pub fn new(username: &str, pass: &str) -> Self {
        let mut hasher = Sha256::new();
        hasher.input_str(pass);
        let password = hasher.result_str();
        let user_id = random_string(100);
        Self {
            username: username.to_string(),
            user_id,
            password,
        }
    }
    /// provides login through selecting this user from a hash map of users (will probably change it to selecting user from file based on username hash)
    /// currently user file isn't encrypted because I thought well password is already encrypted but then realized that the password hash is the same thing that is used to decrypt
    /// the peer files, so will be change that soon, easy solution don't save user files at all
    pub fn login(&self) -> Vec<u8> {
        self.password.clone().into_bytes()
    }
    pub fn username(&self) -> String {
        self.username.clone()
    }
}