34 lines
727 B
Rust
34 lines
727 B
Rust
//! Functions to encrypt the database models
|
|
|
|
pub mod account;
|
|
pub mod hashing;
|
|
pub mod master_pass;
|
|
pub mod passwords;
|
|
pub mod prelude;
|
|
|
|
/// Returns true if the field is valid
|
|
#[inline]
|
|
#[must_use]
|
|
pub fn validate_field(field: &str) -> bool {
|
|
if !(1..255).contains(&field.len()) {
|
|
return false;
|
|
}
|
|
field
|
|
.chars()
|
|
.all(|char| !['`', '\\', '\n', '\t'].contains(&char))
|
|
}
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
pub enum Error {
|
|
#[error("Invalid input length")]
|
|
InvalidInputLength,
|
|
|
|
#[error(transparent)]
|
|
ChaChaError(#[from] chacha20poly1305::Error),
|
|
|
|
#[error(transparent)]
|
|
InvalidUTF8(#[from] std::string::FromUtf8Error),
|
|
}
|
|
|
|
type Result<T> = std::result::Result<T, Error>;
|