Initial commit: Veritas Suite Main Server and Core Engine
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
/// Computes a unique hardware fingerprint (CPU / Machine identifier).
|
||||
pub fn generate_hardware_id() -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
let hostname = std::env::var("COMPUTERNAME")
|
||||
.or_else(|_| std::env::var("HOSTNAME"))
|
||||
.unwrap_or_else(|_| "UNKNOWN-HOST".to_string());
|
||||
|
||||
let username = std::env::var("USERNAME")
|
||||
.or_else(|_| std::env::var("USER"))
|
||||
.unwrap_or_else(|_| "UNKNOWN-USER".to_string());
|
||||
|
||||
let raw_id = format!("{}:{}", hostname, username);
|
||||
hasher.update(raw_id.as_bytes());
|
||||
format!("{:x}", hasher.finalize())
|
||||
}
|
||||
Reference in New Issue
Block a user