CryptGuard: Sign is a comprehensive cryptographic library, offering robust signing and verification capabilities. Designed for developers, CryptGuard: Sign empowers applications to withstand future digital security challenges. Embrace CryptGuard: Sign as your trusted ally in safeguarding privacy in the digital realm.
Ensure your system has the latest stable versions of Rust, Cargo, and the Tokio runtime environment.
The dilithium
feature in CryptGuard: Sign introduces the Dilithium algorithm, a post-quantum cryptographic signing method. This feature is optional and can be enabled in your Cargo.toml
.
To sign a message using Dilithium,
#[cfg(feature = "dilithium")]
#[tokio::main]
async fn main() {
#[cfg(feature = "dilithium")]
{
let mut sign = SignDilithium::new().unwrap();
let message = b"Hello, this is a test message";
// Sign the message
let signed_message = sign.sign_msg(message).await.expect("Failed to sign message with Dilithium");
// Print the signed message
println!("Signed message with Dilithium: {:?}", signed_message);
}
}
To verify a signed message,
#[cfg(feature = "dilithium")]
#[tokio::main]
async fn main() {
#[cfg(feature = "dilithium")]
{
let mut sign = SignDilithium::new().unwrap();
let message = b"Hello, this is a test message";
// Sign the message
let signed_message = sign.sign_msg(message).await.expect("Failed to sign message");
// Verify the signed message
let verification_result = sign.verify_msg(message).await.expect("Failed to verify message");
// Check the verification result
assert!(verification_result, "Verification failed for the signed message with Dilithium");
}
}
For signing a file using Dilithium,
#[cfg(feature = "dilithium")]
#[tokio::main]
async fn main() {
#[cfg(feature = "dilithium")]
{
let mut sign = SignDilithium::new().unwrap();
let file_path = PathBuf::from("path/to/your/file.txt");
// Sign the file
let signed_file = sign.sign_file(file_path.clone()).await.expect("Failed to sign file with Dilithium");
// Print the result
println!("Signed file with Dilithium: {:?}", signed_file);
}
}
These examples demonstrate the usage of the dilithium
feature in CryptGuard: Sign for signing and verifying messages and files, showcasing the library's capabilities with post-quantum cryptography.
To sign a message,
#[tokio::main]
async fn main() {
let mut sign = Sign::new().unwrap();
let message = b"Hello, this is a test message";
// Sign the message
let signed_message = sign.sign_msg(message).await.expect("Failed to sign message");
// Print the signed message
println!("Signed message: {:?}", signed_message);
}
For signing a file,
#[tokio::main]
async fn main() {
let mut sign = Sign::new().unwrap();
let file_path = PathBuf::from("path/to/your/file.txt");
// Sign the file
let signed_file = sign.sign_file(file_path.clone()).await.expect("Failed to sign file");
// Print the result
println!("Signed file content: {:?}", signed_file);
}
CryptGuard: Sign depends on several external crates, specified in Cargo.toml
:
aes
: 0.8.3tokio
: 1.35.1 (withfull
feature)colored
: 2.1.0env
: 0.0.0hex
: 0.4.3hmac
: 0.12.1indicatif
: 0.17.7pqcrypto-falcon
: 0.3.0pqcrypto-dilithium
: 0.5.0pqcrypto-kyber
: 0.8.0pqcrypto-traits
: 0.3.5rand
: 0.8.5sha2
: 0.10.8tempfile
: 3.9.0
CryptGuard: Sign is licensed under the MIT LICENSE. The full license text is available in the LICENSE
file in the repository.
You now have the complete README.md content with the updated examples for CryptGuard.