Crates.io | gm-sm4 |
lib.rs | gm-sm4 |
version | 0.10.0 |
source | src |
created_at | 2023-04-17 02:58:31.044102 |
updated_at | 2023-04-17 03:11:33.78577 |
description | A Rust Implementation of China's Standards of Encryption Algorithms SM4 |
homepage | https://github.com/CrayfishGo/gm-rs.git |
repository | |
max_upload_size | |
id | 841107 |
size | 17,534 |
A Pure Rust High-Performance Implementation of China's Standards of Encryption Algorithms SM4
use crate::Sm4Cipher;
use hex_literal::hex;
fn main() {
let key = hex!("0123456789abcdeffedcba9876543210");
let plaintext = key.clone();
let ciphertext = hex!("681edf34d206965e86b3e94f536e4246");
let cipher = Sm4Cipher::new(&key).unwrap();
let enc = cipher.encrypt(&plaintext).unwrap();
assert_eq!(&ciphertext, enc.as_slice());
}