|
|
@ -14,6 +14,11 @@ use rand::{OsRng, Rng};
|
|
|
|
|
|
|
|
|
|
|
|
const DATABASE_VERSION: u8 = 1;
|
|
|
|
const DATABASE_VERSION: u8 = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct JsonDatabase {
|
|
|
|
|
|
|
|
file_path: PathBuf,
|
|
|
|
|
|
|
|
secret_fn: &'static Fn() -> String,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Database implementation for JSON database
|
|
|
|
// Database implementation for JSON database
|
|
|
|
impl Database for JsonDatabase {
|
|
|
|
impl Database for JsonDatabase {
|
|
|
|
fn get_applications(&self) -> HashMap<String, TOTP> {
|
|
|
|
fn get_applications(&self) -> HashMap<String, TOTP> {
|
|
|
@ -39,11 +44,6 @@ struct DatabaseContentSchema {
|
|
|
|
applications: HashMap<String, TOTP>,
|
|
|
|
applications: HashMap<String, TOTP>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub struct JsonDatabase {
|
|
|
|
|
|
|
|
file_path: PathBuf,
|
|
|
|
|
|
|
|
secret_fn: &'static Fn() -> String,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const IV_SIZE: usize = 16;
|
|
|
|
const IV_SIZE: usize = 16;
|
|
|
|
const KEY_SIZE: usize = 32;
|
|
|
|
const KEY_SIZE: usize = 32;
|
|
|
|
impl JsonDatabase {
|
|
|
|
impl JsonDatabase {
|
|
|
|