use block_modes::block_padding::Pkcs7;
use block_modes::{BlockMode, Ecb};
use des::TdesEde2;
use hex_literal::hex;
type TdesEcb = Ecb<TdesEde2, Pkcs7>;
fn main() {
let key = hex!("000102030405060708090a0b0c0d0e0f");
let iv = hex!("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff");
let plaintext = b"Hello world!";
let cipher = TdesEcb::new_from_slices(&key, &iv).unwrap();
let mut buffer = [0u8; 32];
let pos = plaintext.len();
buffer[..pos].copy_from_slice(plaintext);
let ciphertext = cipher.encrypt(&mut buffer, pos).unwrap();
println!("{:?}", ciphertext);
}
评论区
写评论大概应该是这样,你和你用的对比一下。