https://github.com/yann2192/pyelliptic
Python OpenSSL wrapper. For modern cryptography with ECC, AES, HMAC, Blowfish, ...
https://github.com/yann2192/pyelliptic
Last synced: 15 days ago
JSON representation
Python OpenSSL wrapper. For modern cryptography with ECC, AES, HMAC, Blowfish, ...
- Host: GitHub
- URL: https://github.com/yann2192/pyelliptic
- Owner: yann2192
- License: bsd-2-clause
- Archived: true
- Created: 2011-09-01T19:18:37.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2017-04-25T12:58:27.000Z (over 8 years ago)
- Last Synced: 2025-08-28T05:54:10.365Z (5 months ago)
- Language: Python
- Homepage:
- Size: 124 KB
- Stars: 132
- Watchers: 11
- Forks: 59
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.txt
- License: LICENSE
Awesome Lists containing this project
- awesome-cryptography - PyElliptic - Python OpenSSL wrapper. For modern cryptography with ECC, AES, HMAC, Blowfish. (Frameworks and Libs / Python)
- awesome-cryptography - PyElliptic - Python OpenSSL wrapper. For modern cryptography with ECC, AES, HMAC, Blowfish. (Frameworks and Libs / Python)
- fucking-awesome-cryptography - PyElliptic - Python OpenSSL wrapper. For modern cryptography with ECC, AES, HMAC, Blowfish. (Frameworks and Libs / Python)
README
## WARNING
PyElliptic is **DEPRECATED**.
See https://github.com/yann2192/pyelliptic/issues/50
# PyElliptic
PyElliptic is a high level wrapper for the cryptographic library : OpenSSL.
Under the Berkeley software distribution license (see LICENSE).
Python3 compatible. For GNU/Linux and Windows.
Require OpenSSL
## Features
### Asymmetric cryptography using Elliptic Curve Cryptography (ECC)
* Key agreement : ECDH
* Digital signatures : ECDSA
* Hybrid encryption : ECIES (like RSA)
### Symmetric cryptography
* AES-128 (CBC, OFB, CFB, CTR)
* AES-256 (CBC, OFB, CFB, CTR)
* Blowfish (CFB and CBC)
* RC4
### Other
* CSPRNG
* HMAC (using SHA512)
* PBKDF2 (SHA256 and SHA512)
## Example
```python
#!/usr/bin/python
from binascii import hexlify
import pyelliptic
# Symmetric encryption
iv = pyelliptic.Cipher.gen_IV('aes-256-cfb')
ctx = pyelliptic.Cipher("secretkey", iv, 1, ciphername='aes-256-cfb')
ciphertext = ctx.update('test1')
ciphertext += ctx.update('test2')
ciphertext += ctx.final()
ctx2 = pyelliptic.Cipher("secretkey", iv, 0, ciphername='aes-256-cfb')
print(ctx2.ciphering(ciphertext))
# Asymmetric encryption
alice = pyelliptic.ECC() # default curve: sect283r1
bob = pyelliptic.ECC(curve='sect571r1')
ciphertext = alice.encrypt("Hello Bob", bob.get_pubkey(),
ephemcurve='sect571r1')
print(bob.decrypt(ciphertext))
signature = bob.sign("Hello Alice")
# alice's job :
print(pyelliptic.ECC(pubkey=bob.get_pubkey(),
curve='sect571r1').verify(signature, "Hello Alice"))
# ERROR !!!
try:
key = alice.get_ecdh_key(bob.get_pubkey())
except:
print("For ECDH key agreement, the keys must be defined on the same curve !")
alice = pyelliptic.ECC(curve='sect571r1')
print(hexlify(alice.get_ecdh_key(bob.get_pubkey())))
print(hexlify(bob.get_ecdh_key(alice.get_pubkey())))
```