Expand description

Utility crate for interacting and generating OTP codes from a backup vault from the Android app Aegis Authenticator.

§Example

use aegis_vault_utils::{
    otp::generate_otp,
    vault::{parse_vault, PasswordGetter},
};
use color_eyre::eyre::Result;

// Implement the PasswordGetter trait to get the password from the environment
struct EnvPasswordGetter;
impl PasswordGetter for EnvPasswordGetter {
    fn get_password(&self) -> Result<String> {
        Ok("test".to_string())
    }
}

fn main() -> Result<()> {
    // Read and parse the vault
    let vault_backup_contents = std::fs::read_to_string("res/aegis_encrypted.json")?;
    let db = parse_vault(&vault_backup_contents, &EnvPasswordGetter)?;

    // Get the first entry and generate the OTP code
    let entry = db.entries.iter().next().unwrap();
    let otp = generate_otp(&entry.info)?;

    // Print e.g.: "Deno (Mason): 591295"
    println!("{} ({}): {}", entry.issuer, entry.name, otp);

    Ok(())
}

Modules§

  • Module for generating OTP (One Time Pad) codes
  • The vault is parsed from a JSON file exported from the Aegis app containing database of OTP entries. The database inside the vault can be either plain text or encrypted.