Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/backup/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ pub fn aes_decrypt_cbc_with_padding(data: &[u8], key: &EncryptionKey) -> Result<
}

// Ensure data length is a multiple of 16 bytes (AES block size)
let data_len = if data.len() % 16 != 0 {
data.len() - (data.len() % 16)
} else {
let data_len = if data.len().is_multiple_of(16) {
data.len()
} else {
data.len() - (data.len() % 16)
};

let iv_bytes = [0u8; 16];
Expand Down
2 changes: 1 addition & 1 deletion src/backup/util/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::error::{BackupError, Result};
/// # Errors
/// Returns [`BackupError::HexDecode`] if the string has odd length or invalid chars.
pub(crate) fn hex_decode(hex_string: &str) -> Result<Vec<u8>> {
if hex_string.len() % 2 != 0 {
if !hex_string.len().is_multiple_of(2) {
return Err(BackupError::HexDecode(
"Input string has odd length".to_string(),
));
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![deny(missing_docs)]
#![doc = include_str!("../README.md")]

pub mod backup;
Expand Down