feat: v0.1.0

This commit is contained in:
2023-09-04 00:10:23 +08:00
parent 147f29a9dd
commit e7c311eacb
8 changed files with 230 additions and 17 deletions

12
examples/encrypt.rs Normal file
View File

@@ -0,0 +1,12 @@
use sm4_gcm::Sm4Key;
fn main() {
let key = Sm4Key([0u8; 16]);
let nonce = [0u8; 12];
let plaintext = b"Hello World!";
let ciphertext = sm4_gcm::sm4_gcm_encrypt(&key, &nonce, plaintext);
println!("Encrypted: {}", hex::encode(&ciphertext));
let decrypted = sm4_gcm::sm4_gcm_decrypt(&key, &nonce, &ciphertext).unwrap();
println!("Decrypted: {}", String::from_utf8_lossy(&decrypted));
}