secured-cipher

Crates.iosecured-cipher
lib.rssecured-cipher
version0.4.1
sourcesrc
created_at2023-11-30 21:40:47.308841
updated_at2023-12-19 19:10:18.033072
descriptionPure Rust implementation of the ChaCha cipher family
homepage
repositoryhttps://github.com/mikesposito/secured/
max_upload_size
id1054541
size46,154
Michele Esposito (mikesposito)

documentation

README

Secured-Cipher Library

Overview

secured-cipher is a Rust library offering an implementation of the ChaCha20 and Poly1305 algorithms. It provides both high-level and low-level cryptographic functionalities through a common interface.

Features

  • High-level interfaces for ChaCha20 cipher and Poly1305 authenticator.
  • Common Cipher interface for encryption and decryption operations.
  • core module with low-level crypto operations
  • Flexible usage with support for both raw and high-level cryptographic operations.

Basic Encryption and Decryption Example

Encrypt and decrypt data using the ChaCha20 cipher:

use secured_cipher::Cipher;

let key: [u8; 32] = [0; 32]; // Your key
let nonce: [u8; 12] = [0; 12]; // Your nonce
let data: &[u8] = b"Your data here"; // Data to be encrypted

let mut cipher = Cipher::default();
cipher.init(&key, &nonce);

// Encrypt and decrypt
let encrypted_data = cipher.encrypt(data);
let decrypted_data = cipher.decrypt(&encrypted_data);

// Sign
let signed_secret_envelope = cipher.sign(b"your readable header", &encrypted_data);

// Decrypt and verify
let verified_decrypted_data = cipher.decrypt_and_verify(&signed_secret_envelope);
assert!(verified_decrypted_data.is_ok());

println!("Decrypted and verified data: {:?}", verified_decrypted_data.unwrap());

Installation

Add secured-cipher to your Cargo.toml:

[dependencies]
secured-cipher = "~0.3.1"
Commit count: 30

cargo fmt