Cesare-Liu / cryptokit

cryptokit is a cryptography kit base on pyca Cryptography

Home Page:https://github.com/istommao/cryptokit/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status codecov PyPI PyPI

cryptokit

cryptokit is a cryptography kit base on Cryptography(https://github.com/pyca/cryptography)

Document

You can find more information in the cryptokit documentation.

Feature Support

  • AES Cryptography
  • RSA Cryptography

Installation

pip install cryptokit

AES usage

>>> from cryptokit import AESCrypto
>>> message = "hello cryptokit"
>>> crypto = AESCrypto('WDMG1e38igW53YuxkE0SsKUDeLbULAtL', 'm2VYHdx41zRgvg6f')
>>> data = crypto.encrypt(message)
>>> b'\xaa<\x9d\xe9\xde\x0b\xd7\xe9\xfd\xac\xfc\xdd\x9f\xe2V\xd4'
>>> crypto.decrypt(data)
>>> 'hello cryptokit'

RSA usage

>>> from cryptokit import RSACrypto
>>> private_key = RSACrypto.generate_private_key(2048)
>>> public_key = private_key.public_key()
>>> message = 'Hello cryptokit'
>>> ciphertext = RSACrypto.encrypt(message, public_key, algorithm='sha256')
>>> plaintext = RSACrypto.decrypt(ciphertext, private_key, algorithm='sha256')
>>> plaintext == message
True

PFX usage

>>> from cryptokit import load_pfx, get_pubkey_from_pfx
>>> pkcs12 = load_pfx(pfx_file, password='password')
>>> cert = pkcs12.get_certificate()
>>> pubkey = get_pubkey_from_pfx(pfx_file, password='password')
# or use cert get pubkey
>>> pubkey = cert.get_pubkey().to_cryptography_key()

>>> from cryptokit import generate_pfx
>>> pfx_data = generate_pfx(cert, friendly_name, private_key)

ChangeLog

changelog

License

MIT. See LICENSE for more details.

About

cryptokit is a cryptography kit base on pyca Cryptography

https://github.com/istommao/cryptokit/wiki

License:MIT License


Languages

Language:Python 73.0%Language:HTML 15.7%Language:CSS 9.9%Language:JavaScript 1.3%