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