feat(cli): make flat command structure

This commit is contained in:
2025-10-17 22:53:35 +03:00
parent 54ddcab377
commit 66b440adf6
9 changed files with 258 additions and 215 deletions

View File

@@ -37,6 +37,10 @@ impl Des {
impl BlockCipher for Des {
const BLOCK_SIZE: usize = 8;
fn from_key(key: &[u8]) -> Self {
Self::new(key)
}
fn transform_impl(
&self,
block: &[u8],

View File

@@ -31,6 +31,21 @@ impl From<[u8; 8]> for Key {
}
}
impl From<&[u8]> for Key {
fn from(value: &[u8]) -> Self {
let mut bytes = [0; 8];
let len = value.len().min(8);
bytes[..len].copy_from_slice(&value[..len]);
Self(bytes)
}
}
impl From<u64> for Key {
fn from(key: u64) -> Self {
Self(key.to_be_bytes())
}
}
impl From<Key> for [u8; 8] {
fn from(key: Key) -> Self {
key.0
@@ -43,12 +58,6 @@ impl AsRef<[u8]> for Key {
}
}
impl From<u64> for Key {
fn from(key: u64) -> Self {
Self(key.to_be_bytes())
}
}
impl Debug for Key {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("Key([REDACTED])")