Skip to main content

A library for Ferric Crypto

Project description

Ferric Crypto Lib

This is a collection of cryptographic algorithms implemented in Rust for use during the crypto courses I attend.

The structure of the project might change in the future, but for now it is a single crate with all the algorithms implemented as functions. In the future I might make structs for each algorithm and implement the Encrypt and Decrypt traits for them.

Implemented Algorithms

  • Affine Hill (Custom algorithm)
  • Bernel-Fibonaccis (Custom algorithm)
  • Bifid Chiffre
  • Ceasar
  • DES
  • Dubbel Sick-Sack (Custom algorithm)
  • Enigma
  • Kid-RSA (Custom algorithm)
  • Minigma (Custom algorithm)
  • Hill (no decrypt yet, but simple to do by hand to get a new key)
  • Monoalphabetic
  • MIX (Custom algorithm)
  • Sick-Sack (Custom algorithm)
  • Transposition (no decrypt yet)
  • TrissDES (Custom algorithm)
  • Vernam
  • Vernam (LKG28)
  • Vigenere
  • Vokkon (Custom algorithm)

Usage

Add to your project

Add the following to your Cargo.toml:

From Gitlab

[dependencies]
ferric_crypto_lib = { git = "https://gitlab.com/ferric1/ferric_crypto.git" }

From Path

[dependencies]
ferric_crypto_lib = { path = "/path/to/ferric_crypto" }

Use in your code

All algorithms are implemented as functions in the ferric_crypto_lib crate. To use them, simply import the crate and call the function you want to use. All encryption functions are withing the encrypt module and all decryption functions are within the decrypt module.

Example

TODO: fix example

use ferric_crypto_lib::encrypt::ceasar::*;
use ferric_crypto_lib::decrypt::ceasar::*;

fn main() {
    let encrypted = encrypt("Hello World");
    let decrypted = decrypt(&encrypted);
    println!("Encrypted: {}", encrypted);
    println!("Decrypted: {}", decrypted);
}

Building

Prerequisites

You will need some tools to build the library, click the links to go to the instructions for installing them:

After installing the prerequisites, follow these steps to build:

1. Clone the repository

Using HTTPS

```bash
git clone https://gitlab.com/ferric1/ferric_crypto.git
```

Using SSH

```bash
git clone git@gitlab.com:ferric1/ferric_crypto.git
```

2. Test the library

This is optional, but recommended

just test

3. Build the library

Build for Rust

just build

Build for Python

Here you need Maturin in order to build

just build-py

4. Install the library

If you intend to use the library in a python project, you need to install it. This is done with the following command:

just install-py

This will force install it to your python environment, this is so we dont need to remove it before installing a new version during development.

Development

Adding Crypto Algorithms

To add a new algorithm, simply run this command:

just add-algo <name>

This will create a new file in the src folder with the name <name>.rs and add the following code to it:

use crate::error::CharacterParseError;
use crate::Traits::{Encrypt, Decrypt};

/// Enum representing possible errors in the name cipher.
#[derive(Debug, PartialEq)]
pub enum nameError {
    CharacterParseError(CharacterParseError),
    // Define error variants here
}

/// Represents a name cipher.
#[cfg_attr(feature = "python-integration", pyclass)]
pub struct name {
    // Define struct fields here
}

impl name {
    // Define methods here
    fn new() -> Self {
        Self {
            // Define struct fields here
        }
    }
}

#[cfg(feature = "python-integration")]
mod python_integration {
    use super::*;
    use pyo3::prelude::*;
    use pyo3::{pyclass, PyResult, pymethods};

    #[pymethods]
    impl name {
        // Define Python integration methods here
    }
}

Where we replace name with the name of the new algorithm. This will also add the new algorithm to the mod.rs file inside the src/crypto_systems folder. We also make new standard files for the Encrypt, Decrypt and BruteForce traits in their respective modules, this is where the implementations of the algorithm will go.

You will also need to add the new algorithm to the lib.rs file where we define our python module.

License

This project is licensed under the MIT License - see the LICENSE file for details

Owner

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

ferric_crypto_lib-0.2.6-cp311-cp311-manylinux_2_34_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.34+ x86-64

ferric_crypto_lib-0.2.6-cp310-cp310-manylinux_2_34_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

ferric_crypto_lib-0.2.6-cp39-cp39-manylinux_2_34_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.34+ x86-64

ferric_crypto_lib-0.2.6-cp38-cp38-manylinux_2_34_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.34+ x86-64

ferric_crypto_lib-0.2.6-cp37-cp37m-manylinux_2_34_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.34+ x86-64

File details

Details for the file ferric_crypto_lib-0.2.6-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ferric_crypto_lib-0.2.6-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6458fb91adbd2bf49a837f734d5f490d131c0e1d5a33f53d277f31038facedfa
MD5 9c21b56029ae4f3bca51e9f0f6b054fa
BLAKE2b-256 535989565a8e6bb014921d5a2db868430fd3f69e38f2e0536f814c948e27bf08

See more details on using hashes here.

File details

Details for the file ferric_crypto_lib-0.2.6-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ferric_crypto_lib-0.2.6-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e63d3698e40d34d996c58a8e0fedc0bad70736ad359fcfea0e28aa665e6714fc
MD5 96df093d808e9ac9d6d6f7fd0bdd7191
BLAKE2b-256 7ea76035a126c0ac4a7aa539f0d9fffe589cecaad3858737d78d77a440e360df

See more details on using hashes here.

File details

Details for the file ferric_crypto_lib-0.2.6-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ferric_crypto_lib-0.2.6-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e8b13c7f665225a2489ea5443e1a2bcce3b37852f468a989d7fe1f5e13804a0f
MD5 5493bfe9136f3d382c60782def8f0ede
BLAKE2b-256 b19a6bbab43f8b59e69e2d3f986dd4620b75b4a80e7f3cda907cd3d511239067

See more details on using hashes here.

File details

Details for the file ferric_crypto_lib-0.2.6-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ferric_crypto_lib-0.2.6-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a8612c51873871182c46b63bb8c8d4d97ed332ead45284128641320a11d3c439
MD5 cbdec584d5dc32c6be18553c34833468
BLAKE2b-256 195d5edd4fab75b4b079665a49f7e8e7f1cc5e7662916f595388a253b0555f6b

See more details on using hashes here.

File details

Details for the file ferric_crypto_lib-0.2.6-cp37-cp37m-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ferric_crypto_lib-0.2.6-cp37-cp37m-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5166872f05dee5ac867b5bc35a3219d6f822b9c55df5bab0badbdca0966507b1
MD5 edd6bdaba6d048c7dd5b4a0623da83a5
BLAKE2b-256 3fb07f3f5a6aa6235d01a5a3e9f0735b276447945498b044af7c7d1dd92f9ca4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page