Expand description
DES Encryption support for ZUS RPC protocol
This module provides DES-ECB encryption/decryption compatible with the C++ and Java ZUS implementations.
§Encryption Details
- Algorithm: DES (Data Encryption Standard)
- Mode: ECB (Electronic Codebook)
- Padding: Zero-padding to 8-byte blocks
- Key size: 8 bytes (64 bits, with 56 effective bits)
§Cross-Language Compatibility
This implementation is compatible with:
- C++:
zus::DesEncryptclass indes.cpp - Java:
CryptUtil.desEncrypt()/CryptUtil.desDecrypt()inCryptUtil.java
§Example
use zus_common::encryption::{DesEncryptor, encrypt_des, decrypt_des};
// Using the simple functions
let key = b"12345678";
let plaintext = b"Hello, World!";
let encrypted = encrypt_des(plaintext, key).unwrap();
let decrypted = decrypt_des(&encrypted, key).unwrap();
assert_eq!(&decrypted[..plaintext.len()], plaintext);
// Using the DesEncryptor for multiple operations
let encryptor = DesEncryptor::new(key);
let encrypted = encryptor.encrypt(plaintext).unwrap();
let decrypted = encryptor.decrypt(&encrypted).unwrap();Structs§
- DesEncryptor
- DES Encryptor for encrypting and decrypting data using DES-ECB mode.
Constants§
- DES_
BLOCK_ SIZE - DES block size in bytes
- DES_
KEY_ SIZE - DES key size in bytes
Functions§
- decrypt_
des - Decrypt data using DES-ECB mode.
- encrypt_
des - Encrypt data using DES-ECB mode with zero-padding.