Skip to main content

Simple symmetric encryption and decryption (ECB) for text

Project description

SH Crypt

PyPI Latest Release License codecov CircleCI

A simple symetric encyption decryption algorithm

About

SH Crypt is base on library cryptography algorithm and use more specifically the Electronic Code Book (ECB) for symetric encryption and decryption.

Here are some code example to use the library.

Generate a key, encrypt and decrypt text

from sh_crypt import GenKeySH, SymCryptSH, AsymCryptSH
import random as rnd

###############################
## Symetric Cipher

# Create key generator
seed = rnd.randint(1, 1e12)
key_gen = GenKeySH(seed)

key = key_gen.gen_sym_key(path_store="mykey.txt")
# Ex : 'e169344ae15719669ed2fecea1ac4773'

password = "Hello World !!"

crypt = CryptSH(key)

encrypt_password = crypt.encrypt_message(password)
# Ex : '469feb93adc2af609a98e6b7cee859bb'

crypt.decrypt_message(encrypt_password)
# 'Hello World !!'

###############################
## Asymetric Cipher

key_gen = GenKeySH()

priv_key, public_key = key_gen.gen_asym_key()
# We can store the key with parameters path_store="file_path".

crypt = AsymCryptSH()

crypt.add_key(priv_key)
crypt.add_key(public_key)

message = "Hello World !!!"

# Encrypt / Decrypt Message
message_enc = crypt.encrypt_message(message)

crypt.decrypt_message(message_enc)

# Sign message / check signature

signature = crypt.sign_message(message)

if crypt.check_sign_message(signature, message):
    print("Signature is valid")
else:
    print("Signature is invalid")

As you can see in the example, you can store your generated key in a text file and reuse it later, with the path_store argument.

Install

You can install sh-crypt with pip:

pip install sh-crypt

or download the sh-crypt source, choose your version, and install with the command:

python setup.py install

Project details


Download files

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

Source Distribution

sh-crypt-1.2.1.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

sh_crypt-1.2.1-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

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