Crates.io | ferric_crypto_lib |
lib.rs | ferric_crypto_lib |
version | 0.2.7 |
source | src |
created_at | 2023-12-09 05:25:49.231122 |
updated_at | 2024-01-03 11:53:05.825624 |
description | A library for Ferric Crypto |
homepage | https://gitlab.com/ferric1/ferric_crypto |
repository | https://gitlab.com/ferric1/ferric_crypto |
max_upload_size | |
id | 1063421 |
size | 224,323 |
This Lib is in pre-pre-pre-pre-alpha at the moment and therefore cannot be trusted in prod, also the documentation is not accurate at the moment
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.
Add the following to your Cargo.toml
:
[dependencies]
ferric_crypto_lib = { git = "https://gitlab.com/ferric1/ferric_crypto.git" }
[dependencies]
ferric_crypto_lib = { path = "/path/to/ferric_crypto" }
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.
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);
}
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:
```bash
git clone https://gitlab.com/ferric1/ferric_crypto.git
```
```bash
git clone git@gitlab.com:ferric1/ferric_crypto.git
```
This is optional, but recommended
just test
just build
Here you need Maturin in order to build
just build-py
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.
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.
This project is licensed under the MIT License - see the LICENSE file for details