plain-aes

Crates.ioplain-aes
lib.rsplain-aes
version0.1.1
sourcesrc
created_at2024-09-28 21:59:17.435027
updated_at2024-09-28 22:10:09.051457
descriptionAn implementation of Rijndael's cipher, commonly known as AES.
homepage
repositoryhttps://github.com/emdCatalyst/plain-aes
max_upload_size
id1390397
size145,003
mahdi (emdCatalyst)

documentation

README

plain-aes  codecov badge build status badge docs.rs status

An implementation of Rijndael's cipher, commonly known as Advanced Encryption Standard.


Features

  • Based on FIPS 197 Final.
  • Thoroughly tested and documented.
  • Implements AES-128/192 encryption and decryption.
  • Implements the following modes of operation:
    • Electronic CodeBook.
    • Cipher Block Chaining.
  • Ability to implement your own mode of operation, using the block operations exposed by the crate's internal module.
  • Out of the box support for &[str] and &[u8] encryption/decryption.
  • Ability to encrypt/decrypt any custom data structure that implements the Encryptable trait.

Usage

To use the crate, either add plain-aes to your Cargo.toml's dependecies, or run cargo add plain-aes.
Here's a quick example on how to encrypt a text message in AES128-ECB:

use plain_aes::{encrypt, ModeOfOperation, CipherVersion};
let message = "This is a super secret message";
let key = "This lib is cool"; // This lib is cool
let encrypted_message = encrypt(message, CipherVersion::Aes128(key.as_bytes(), ModeOfOperation::ECB)).unwrap();
let expected_enrypted: &[u8] = &[
   0x11, 0x2B, 0xBD, 0x0D, 0x4C, 0x0C, 0xC5, 0x02, 0xB4, 0xC1, 0x38, 0xFD, 0x9A, 0x56,
    0xC1, 0xA8, 0x78, 0x61, 0xD9, 0xF5, 0x6B, 0x48, 0xCC, 0xC5, 0x48, 0x14, 0xF2, 0x8C,
    0x1A, 0x25, 0x11, 0xA3,
];
assert!(expected_enrypted.iter().eq(encrypted_message.iter()))

Refer to the docs, or the tests folder for in-depth examples and documentation.

Test coverage

  • This crate is tested using tarpaulin.
  • Currently boasts a 100% line coverage.
  • See the project's codecov page for more information.

License   license

This project is licensed under both the MIT and Apache 2.0 License. See LICENSE-APACHE and LICENSE-MIT for details.

Disclaimer

This crate is intended for educational and experimental purposes only and should not be used in production environments. For security-critical applications, it is strongly recommended to use established and well-tested cryptographic libraries that have undergone rigorous security audits. The author shall not be liable for any damages, including but not limited to direct, indirect, incidental, special, exemplary, or consequential damages, arising out of or in connection with the use or inability to use this crate.

Commit count: 4

cargo fmt