Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Azadeh Afzar - Mersad Cryptographic Library

Project description


Mersad Cryptography Library

Mersad Cryptography Library

A side project of a Telecommunication student who loves ciphers.

Open Source License: AGPL v3 Language counter Top language
CodeFactor CodeClimate rating Scrutinizer-ci rating CodeClimate technical debt CodeClimate issues
pipeline status travis build status CodeClimate
PyPI version PyPI downloads Supported Python versions

If you want to do any serious jobs :poop: with this tool, prepare yourself to get fired :fire:!

Why is Gamora?

In summer 2019 I had decided to practice Python and DevOps tasks like: continuous integration and automated releasing software to packaging sources like pypi, I don't know how I ended up here writing this for you! (even like if there is any "you" out there looking at this little side project of mine.)

So if you want to send unbreakable messages to your friends with ancient algorithms without using pen and paper, Mersad can help you. (but seriously, :joy: unbreakable? c'mon!)

Oh and I :heart: codes and ciphers!

Quick start

I'm sure you have worked with Python before and you are familiar with how to download and install packages using pip, so here is how to install this totally (not at all) secure package:

# 1. if you are an uncivilised savage living in a hell of dependency conflicts who doesn't 
# even heard of virtual environments and always install packages in sudo mode, here you go:
sudo -H pip3 install mersad
# or just use a little bit better non-sudo thing
pip3 install --user mersad

# 2. if you are a man of culture, activate your virtual environment and type this:
pip3 install mersad
# pipenv is also a good thing to use (only heroes use it
pipenv install mersad

Wait a second, What's Cryptography?

Honestly? I don't know either ... :grimacing:. smart guys gather together to invent a way for communicating with their lovers in secret and other (literally) more smart guys will try to find a way to break their code and read their love messages (they succeed), but they are enough stupid to tell everyone about it, so first group will try to find new encryption algorithms for their messages. This never ending cycle continues until today.

Apparently people are calling the work of first group (designing encryption algorithms) "Cryptography" and the work of second group (breaking those stupid ciphers) "Cryptanalysis".

How does this package work?

Good question, it doesn't.

But if you are so smart and managed to make it work for you, here is some explanation about the mess that is going on:

Mersad is divided into two main sub-packages, classical and modern, I'm currently developing classical algorithms but in future I will start working on modern ones.

I'm also planning to add cryptanalysis module, this module will contains programs to break ciphers.

Each cipher has a class and a translator function, you can use any of them or both of them together. the translator function is no memory and requires every argument in each call but class have memory and can store key, alphabet and etc.

Example

It is a very simple example of using Shift cipher (aka Caesar cipher) :

from mersad.classical.shift_cipher import ShiftCipher, shift_cipher_translator

MESSAGE = "Hail Caesar!"
ALPHABET = "abcdefghijklmnopqrstuvwxyz"
KEY = 4

CIPHER = shift_cipher_translator(MESSAGE, key=KEY, letter_sequence=ALPHABET)
print(CIPHER)
# Out: Hemp Ceiwev!

# with translator function you need to pass all arguments
# in each call again and again.

# now the  second way of using shift cipher is using the class instead of function.

# create object without any keyword arguments so agent will use
# default values for all the settings. defaults are predefined in class.
agent = ShiftCipher()

# override defaults.
agent.config(key=3453, letter_sequence=ALPHABET)

# also you can do it at the time yu creat object:
# agent = ShiftCipher(key=3453, letter_sequence=ALPHABET)

# config usage is to override any existing properties with 
# new values at any time after creating the object.

# encrypt a string.
print(agent.encrypt("Hail Julius Caesar."))
# Out:  'Hvdg Jpgdpn Cvznvm.'

# with this object approach you don't need to pass every thing in each call to
# encrypt or decrypt.
# another one
print(agent.encrypt("This method is not secure :0 but it is funny."))
# Out: Tcdn hzocjy dn ijo nzxpmz :0 wpo do dn apiit.

# for decryption simply call decrypt method on agent
print(agent.decrypt("This method is not secure :0 but it is funny."))
# Out: Tcdn hzocjy dn ijo nzxpmz :0 wpo do dn apiit.

for more examples look at snippets.

Can I use this package in terminal?

Yes! :metal:

Each cipher module have a corresponding cli program with name convention of: mclModuleName. For example to run Shift cipher module in terminal just type mclShift. To learn how to work with cli programs type --help after program name (e.g. mclShift --help).

Contribution

If you want to contribute to this project, please read CONTRIBUTING.

Code of Conduct

Visit the Code of Conduct.

Roadmap

Visit the Roadmap to keep track of which features we are currently working on and which futures will come at future.

License

Licensed under the AGPLv3.

Attribution

Project details


Download files

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

Files for mersad, version 0.0.17
Filename, size File type Python version Upload date Hashes
Filename, size mersad-0.0.17.tar.gz (26.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page