Advanced Encryption Standard (AES) NumPy implementation
Project description
npaes
Advanced Encryption Standard (AES) NumPy implementation.
Warning: incomplete & not yet suitable for production use. See the "Caution" section below.
Supports | Python 2.7 | 3.5 | 3.6 | 3.7 |
Latest Release | |
Package Status | |
License |
This package implements the Advanced Encryption Standard (AES) as specified in Federal Information Processing Standards Publication 197 ("FIPS197"):
This implementation is based entirely and solely on FIPS197. The tests in tests/test_npaes.py
use the full set of example vectors from Appendix A, B, and C of FIPS197. npaes
supports AES-128, AES-192, and AES-256.
Its sole dependencies is NumPy. It does not use OpenSSL or any other C libraries besides the portions of NumPy that are implemented in C.
Additional technical notes can be found in the docstring of npaes/__init__.py
.
Caution
This package is incomplete. While the raw encryption and decryption are fully tested using the FIPS197 example vectors, it is incomplete for the following reasons:
- It does not allow you to specify an initialization vector (IV).
- It does not allow you to specify a block mode.
- It is optimized in most places but not all, and has little to no chance of ever being as fast as the optimized ANSI C version in OpenSSL.
Basic Usage
import os
from npaes import AES
# Key must be bytes type and 128, 192, or 256 bits
# Or use hashlib.sha256() for an off-length key
key = os.urandom(32) # 256-bit key
# Your plaintext length must be bytes and a multiple of 16 length
msg = b"a secret message goes here" + 6 * b"\x03"
cipher = AES(key)
ciphertext = cipher.encrypt(msg)
print(ciphertext)
# b'a\x85cna\xc2\xeeu\xe9S\xdf\xabE\x0c\xda\xf4\x19\x11\xa3!\xdd\x96-\x85\x10f\xd4\x18;s%\x81'
print(cipher.decrypt(ciphertext))
# b'a secret message goes here\x03\x03\x03\x03\x03\x03'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file npaes-0.3.tar.gz
.
File metadata
- Download URL: npaes-0.3.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b125ab13aaf7291d755072bf3284572a5c24cae9d915ceb1eaf219f76454adda |
|
MD5 | dcc61f7ae05ed638d4f20dc47d86abdb |
|
BLAKE2b-256 | 9a6091aec9ee48ed7dca6505b7ce9466a379dd8cf677dd5a5688389b096f7446 |
File details
Details for the file npaes-0.3-py3-none-any.whl
.
File metadata
- Download URL: npaes-0.3-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb2dca4b0a2eb79f20dbd4466e587de4a3dde787d2fd48d8e9a118c5669f59bd |
|
MD5 | ade75b1be6047b138f5afbc964261e59 |
|
BLAKE2b-256 | 8cceddc35ded11e114ca3549b06456420fba1a4f811abec4153842cdfaeabe12 |