pub struct AskryptFile {
pub version: String,
pub question0: String,
pub params: KdfParams,
pub qs: String,
pub master: String,
pub data: String,
}Expand description
Main Askrypt file structure in JSON format
Fields§
§version: String§question0: String§params: KdfParams§qs: String§master: String§data: StringImplementations§
Source§impl AskryptFile
impl AskryptFile
Sourcepub fn create(
questions: Vec<String>,
answers: Vec<String>,
secret_data: Vec<SecretEntry>,
iterations0: Option<u32>,
iterations1: Option<u32>,
) -> Result<Self, Box<dyn Error>>
pub fn create( questions: Vec<String>, answers: Vec<String>, secret_data: Vec<SecretEntry>, iterations0: Option<u32>, iterations1: Option<u32>, ) -> Result<Self, Box<dyn Error>>
Create a new AskryptFile from questions, answers, and secret data
§Arguments
questions- A vector of at least 2 questionsanswers- A vector of normalized answers (must be pre-normalized, same length as questions)secret_data- A vector of SecretEntry items to encryptiterations0- Optional iterations for first KDF (default: 600000)iterations1- Optional iterations for second KDF (default: 600000)
§Returns
Returns a Result containing the AskryptFile or an error
§Example
use askrypt::{AskryptFile, SecretEntry};
let questions = vec![
"What is your mother's maiden name?".to_string(),
"What was your first pet's name?".to_string(),
"What city were you born in?".to_string(),
];
let answers = vec![
"Smith".to_string(),
"Fluffy".to_string(),
"New York".to_string(),
];
let data = vec![
SecretEntry {
name: "example".to_string(),
secret: "password123".to_string(),
url: "https://example.com".to_string(),
notes: "My account".to_string(),
entry_type: "password".to_string(),
tags: vec![],
created: "2024-01-01T00:00:00Z".to_string(),
modified: "2024-01-01T00:00:00Z".to_string(),
}
];
let askrypt_file = AskryptFile::create(questions, answers, data, Some(6000), Some(6000)).unwrap();Sourcepub fn decrypt(
&self,
questions_data: QuestionsData,
answers: Vec<String>,
) -> Result<Vec<SecretEntry>, Box<dyn Error>>
pub fn decrypt( &self, questions_data: QuestionsData, answers: Vec<String>, ) -> Result<Vec<SecretEntry>, Box<dyn Error>>
Decrypt an AskryptFile and retrieve the secret data using the answers
§Arguments
answers- A vector of normalized answers (must be pre-normalized)
§Returns
Returns a Result containing the decrypted Vec
§Example
use askrypt::{AskryptFile, SecretEntry };
let questions = vec![
"What is your mother's maiden name?".to_string(),
"What was your first pet's name?".to_string(),
"What city were you born in?".to_string(),
];
let answers = vec![
"Smith".to_string(),
"Fluffy".to_string(),
"New York".to_string(),
];
let data = vec![
SecretEntry {
name: "example".to_string(),
secret: "password123".to_string(),
url: "https://example.com".to_string(),
notes: "My account".to_string(),
entry_type: "password".to_string(),
tags: vec![],
created: "2024-01-01T00:00:00Z".to_string(),
modified: "2024-01-01T00:00:00Z".to_string(),
}
];
let askrypt_file = AskryptFile::create(questions, answers.clone(), data.clone(), Some(6000), Some(6000)).unwrap();
let questions_data = askrypt_file.get_questions_data(answers[0].clone()).unwrap();
let decrypted_data = askrypt_file.decrypt(questions_data, answers[1..].into()).unwrap();
assert_eq!(decrypted_data, data);Sourcepub fn get_questions_data(
&self,
first_answer: String,
) -> Result<QuestionsData, Box<dyn Error>>
pub fn get_questions_data( &self, first_answer: String, ) -> Result<QuestionsData, Box<dyn Error>>
Trait Implementations§
Source§impl Clone for AskryptFile
impl Clone for AskryptFile
Source§fn clone(&self) -> AskryptFile
fn clone(&self) -> AskryptFile
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AskryptFile
impl Debug for AskryptFile
Source§impl<'de> Deserialize<'de> for AskryptFile
impl<'de> Deserialize<'de> for AskryptFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for AskryptFile
impl PartialEq for AskryptFile
Source§impl Serialize for AskryptFile
impl Serialize for AskryptFile
impl StructuralPartialEq for AskryptFile
Auto Trait Implementations§
impl Freeze for AskryptFile
impl RefUnwindSafe for AskryptFile
impl Send for AskryptFile
impl Sync for AskryptFile
impl Unpin for AskryptFile
impl UnwindSafe for AskryptFile
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)