ferric_crypto_lib 0.2.7

A library for Ferric Crypto
Documentation
#![allow(dead_code)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// TODO: Make sure we follow the standard for Alphabet usage in the crypto systems
// Should be uppercase for encrypted text and lowercase for plain text, and the alphabet should be
// the sweedish alphabet without 'w', meaning there are 28 characters in the alphabet, we index from
// 0 to 27, and in most cases we use modulo 28 for calculations.

//! # Ferric Cryptography Library
//! The `lib.rs` file is the root of the library crate.
//! It is the entry point for the library.
//! It contains several modules that are part of the library.
//!
//! # Notes
//! - The library is still in development and is not ready for production use.
//! - The library is not yet fully documented and includes some things to be implemented in the future.

#[macro_use]
extern crate lazy_static;

/// # Prelude module
/// The `prelude` module.
///
/// This module contains all the necessary imports and types that are used throughout the library.
///
/// # Notes
// TODO: Move utils to utils module
/// - The `prelude` module currently includes utils that will be moved to the `utils` module in the future.
pub mod prelude;

/// # Crypto Systems module
/// The `crypto_systems` module.
///
/// This module contains various cryptographic systems that are used in the library.
///
/// # Notes
/// - Currently refractoring to move crypto systems in here.
/// Currently both `Ceasar` and `Hill` are in here, the rest are standalone functions
pub mod crypto_systems;

/// The `Traits` module.
///
/// This module contains various traits that are used in the library.
pub mod Traits;

/// The `encrypt` module.
///
/// This module contains functionality for encrypting data.
pub mod encrypt;

/// The `decrypt` module.
///
/// This module contains functionality for decrypting data.
pub mod decrypt;

/// The `challanges` module.
///
/// This module contains various cryptographic challenges.
pub mod challanges;

mod brute_force;
pub mod error;
pub mod utils;

#[cfg(feature = "python-integration")]
use pyo3::{pyfunction, pymodule, types::PyModule, PyResult, Python};

#[cfg(feature = "python-integration")]
#[pymodule]
#[pyo3(name = "ferric_crypto_lib")]
fn ferric_crypto_lib(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
    println!("Ferric Crypto Lib Python Module Loaded");

    use crate::utils::{
        decode_digit, decode_list, encode_char, encode_string, num_gcd, print_info,
        python_integration::factorize_n,
    };

    // format for adding a crypto system to the python module
    // m.add_class::<path::to::struct>()?;
    m.add_class::<crypto_systems::affine::Affine>()?;
    m.add_class::<crypto_systems::ceasar::Ceasar>()?;
    m.add_class::<crypto_systems::mix::Mix>()?;
    m.add_class::<crypto_systems::mix::MixKey>()?;
    m.add_class::<crypto_systems::mono_alphabet::Monosubstitution>()?;
    m.add_class::<crypto_systems::hill_crypto::Hill>()?;
    m.add_class::<crypto_systems::hill_crypto::HillDirection>()?;
    m.add_class::<crypto_systems::rsa::RSA>()?;
    m.add_class::<crypto_systems::des::DES>()?;
    m.add_class::<crypto_systems::vigenere::Vigenere>()?;
    m.add_class::<crypto_systems::vahf::Vahf>()?;
    m.add_class::<utils::python_integration::PyBaseString>()?;
    m.add_class::<utils::python_integration::PyEncodedString>()?;
    m.add_class::<utils::BaseString>()?;
    m.add_class::<utils::EncodedString>()?;
    m.add_function(pyo3::wrap_pyfunction!(print_info, m)?)?;
    m.add_function(pyo3::wrap_pyfunction!(encode_string, m)?)?;
    m.add_function(pyo3::wrap_pyfunction!(encode_char, m)?)?;
    m.add_function(pyo3::wrap_pyfunction!(decode_list, m)?)?;
    m.add_function(pyo3::wrap_pyfunction!(decode_digit, m)?)?;
    m.add_function(pyo3::wrap_pyfunction!(num_gcd, m)?)?;
    m.add_function(pyo3::wrap_pyfunction!(factorize_n, m)?)?;

    Ok(())
}