spytrap-adb 0.3.5

Test a phone for stalkerware using adb and usb debugging to scan for suspicious apps and configuration
Documentation
use chrono::{TimeZone, offset::Utc};
use sha2::{Digest, Sha256};

pub fn human_option_str(x: Option<&String>) -> &str {
    if let Some(x) = x { x.as_str() } else { "-" }
}

pub fn now() -> i64 {
    let now = chrono::offset::Utc::now();
    now.timestamp()
}

pub fn format_datetime(timestamp: i64) -> String {
    let utc = Utc.timestamp_opt(timestamp, 0).unwrap();
    utc.format("%Y-%m-%d %H:%M UTC").to_string()
}

pub fn sha256(buf: &[u8]) -> String {
    let mut sha256 = Sha256::new();
    sha256.update(buf);
    hex::encode(sha256.finalize())
}