MyCrptool
A python package that include commonly used cryptographic algorithm and tools.
Install
pip install mycrptool
Dependencies
Here are external libraries that is used in this package.
bitarray
Usage
This package consists of 4 parts: symmetric, asymetric, hash, and tools.
To import all modules, it is recommanded to run from mycryptool import *
symmetric
This module includes 2 symmetric algorithms: AES128 and DES.
AES128
The Default scheme is CBC. if you want to try other schemes, welcome to explore the AES class (in symmetric.aes128).
Encrypt:
data = b'Jessie Pinkman in the house'
key = 'key'
cipher = symmetric.aes128.encrypt(key, data)
Decrypt:
symmetric.aes128.decrypt(key, cipher)
DES
DES only supports 2 schemes: CBC and ECB. Supported Features: encrypt and decrypt.
Encrypt:
key = b'chopperc'
iv = b'66666666'
data = b'Yo Yo Yo, Jessie Pinkman in the house!!!'
cipher = symmetric.des.des_cbc(data, iv, key, True) # CBC
cipher = symmetric.des.des_ecb(data, key, True) # ECB
Decrypt:
deciphered = symmetric.des.des_cbc(cipher, iv, key, False) # CBC
deciphered = symmetric.des.des_ecb(cipher, key, False) # ECB
asymmetric
This module includes 2 asymmetric algorithms: RSA and Elliptic Curve.
Supported Features: encrypt, decrypt, generate signature, and validate signature.
RSA
Encrypt:
data = b'Jessie Pinkman in the house'
# Warning: it takes a while to generate key pairs ( large prime numbers).
pub, pri = asymmetric.rsa.generate_key_pair()
cipher = asymmetric.rsa.encrypt(data, pub)
Decrypt:
asymmetric.rsa.decrypt(cipher, pri)
Generate signature:
signature = asymmetric.rsa.get_signature(hash.md5.md5(data), pri)
print(signature)
Validate signature:
asymmetric.rsa.is_valid_signature(hash.md5.md5(data), signature, pub)
Elliptic Curve
As for now, this module only supports 1 curve: ecp256k1.
However, you can Implement your own curve derived from the EllipticCurve class.
Implement customize curve:
class ecp256k1(EllipticCurve):
# ecp256k1 https://www.secg.org/sec2-v2.pdf
def __init__(self):
a = 0
b = 7
p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
Gx = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798
Gy = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8
n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
super(ecp256k1, self).__init__(a, b, p, (Gx, Gy), n)
Encrypt:
ec = asymmetric.elliptic_curve.ecp256k1()
pri = ec.get_private_key()
pub = ec.get_public_key(pri)
ec_cipher = ec.encrypt(data, pub)
print(ec_cipher)
Decrypt:
ec.decrypt(ec_cipher, pri)
Generate signature:
signature = ec.get_signature(hash.sha1.sha1(data), pri)
Validate signature:
ec.is_valid_signature(hash.sha1.sha1(data), signature, pub)
Metadata
Release files for mycryptool 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mycryptool-1.1.tar.gz | 14.5 kB | Without provenance | Details for mycryptool-1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mycryptool-1.1-py3-none-any.whl | Python 3 | none | any | Details for mycryptool-1.1-py3-none-any.whl |
Total release size: 30.9 kB
Release files / mycryptool-1.1.tar.gz
| Download URL | mycryptool-1.1.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9100b73e1b28af34692d339ace0a3b6b55bb850ebdb84d73c04399a2be7c9a00
|
|
BLAKE2b-256 checksum How to use checksums |
613518558a99764bea20403c2905ae31f1b89cc7f9742b92ab542806317b117e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.5
|
Release files / mycryptool-1.1-py3-none-any.whl
| Download URL | mycryptool-1.1-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4ae1c327b2db9ff214414217295770a9f2f6158a805e5d9e46c8346bb548bec
|
|
BLAKE2b-256 checksum How to use checksums |
bacda491ef4dceb94ca86ecab3000b87517a686b96c90332eca6e260af3f42e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.5
|
Security for mycryptool 1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.