rust-nex/rnex-core/src/nex/account.rs

38 lines
865 B
Rust
Raw Normal View History

2025-06-29 11:40:42 +02:00
use macros::RmcSerialize;
2025-02-01 17:18:52 +01:00
2026-01-31 13:48:06 +01:00
#[derive(RmcSerialize, Clone)]
pub struct Account {
pub pid: u32,
2025-06-29 11:40:42 +02:00
pub username: String,
pub kerbros_password: [u8; 16],
2025-02-01 17:18:52 +01:00
}
2026-01-31 13:48:06 +01:00
impl Account {
pub fn new(pid: u32, username: &str, passwd: &str) -> Self {
let passwd_data = passwd.as_bytes();
let mut passwd = [0u8; 16];
2026-01-31 13:48:06 +01:00
for (idx, byte) in passwd_data.iter().enumerate() {
passwd[idx] = *byte;
}
2026-01-31 13:48:06 +01:00
Self {
kerbros_password: passwd,
username: username.into(),
2026-01-31 13:48:06 +01:00
pid,
}
}
2026-01-31 13:48:06 +01:00
pub fn new_raw_password(pid: u32, username: &str, passwd: [u8; 16]) -> Self {
Self {
kerbros_password: passwd,
username: username.into(),
2026-01-31 13:48:06 +01:00
pid,
2025-02-01 17:18:52 +01:00
}
}
2026-01-31 13:48:06 +01:00
pub fn get_login_data(&self) -> (u32, &[u8]) {
(self.pid, &self.kerbros_password)
}
2026-01-31 13:48:06 +01:00
}