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,
}
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,
}
}
pub fn login(&self) -> Vec<u8> {
self.password.clone().into_bytes()
}
pub fn username(&self) -> String {
self.username.clone()
}
}