#openssl #symmetric #async #stream #symm

async_symm_crypto

An async openssl symmetric cryptography

2 releases

new 0.1.1 Jan 8, 2025
0.1.0 Jan 8, 2025

#756 in Cryptography

Download history 102/week @ 2025-01-03

102 downloads per month

MIT license

32KB
361 lines

Async-Symm-Crypto

A crate that wraps around openssl providing very convenient async interfaces to openssl's symmetric cryptography functions. It is:

Crates.io Crates.io Docs Build MIT licensed

Website | API Docs

Example

Basic example of stream cryptography

Make sure openssl is installed on the operating

[dependencies]
async_symm_crypto = "0.1.1"

Then, on your main.rs:

use async_symm_crypto::AsyncEncryption;
use futures::StreamExt;
use std::ops::Deref;
use tokio;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let crypto = AsyncEncryption::new(
        openssl::symm::Cipher::des_ede3_cbc(),
        TEST_KEY,
        Some(b"bcff0511"),
    );

    let mut enc_stream = crypto.encrypt_stream(get_text_byte_stream());

    let mut enc_bytes = Vec::new();

    while let Some(Ok(part)) = enc_stream.next().await {
        enc_bytes.extend_from_slice(part.deref());
    }
}

Contributing

🎈 Contributions are very welcome to improve the project.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, shall be licensed as MIT, without any additional terms or conditions.

I'm looking to get hired

If you like my work, please let me know by recommending me for rust jobs.

Dependencies

~2.5–3.5MB
~79K SLoC