mirror of
https://github.com/kristoferssolo/cipher-workshop.git
synced 2026-02-04 06:42:11 +00:00
feat(cli): add AES to cli app
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use cipher_core::{BlockCipher, InputBlock};
|
||||
use des::Des;
|
||||
use std::fmt::Display;
|
||||
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
@@ -9,16 +7,6 @@ pub enum Algorithm {
|
||||
Aes,
|
||||
}
|
||||
|
||||
impl Algorithm {
|
||||
#[must_use]
|
||||
pub fn get_cipher(&self, key: &impl InputBlock) -> impl BlockCipher {
|
||||
match self {
|
||||
Self::Des => Des::from_key(key.as_bytes()),
|
||||
Self::Aes => todo!("Must implement AES first"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Algorithm {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let s = match self {
|
||||
|
||||
@@ -18,9 +18,9 @@ impl OutputFormat {
|
||||
#[must_use]
|
||||
pub fn to_string(&self, value: &Output) -> String {
|
||||
match self {
|
||||
Self::Binary => format!("{value:064b}"),
|
||||
Self::Octal => format!("{value:022o}"),
|
||||
Self::Hex => format!("{value:016X}"),
|
||||
Self::Binary => format!("{value:b}"),
|
||||
Self::Octal => format!("{value:o}"),
|
||||
Self::Hex => format!("{value:X}"),
|
||||
Self::Text => format!("{value}"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user