Skip to main content

npaes

PyPI version Python versions License: Apache-2.0

Advanced Encryption Standard (AES) NumPy implementation.

Warning: incomplete and not suitable for production use. See the Caution section.

Overview

This package implements the Advanced Encryption Standard (AES) as specified in Federal Information Processing Standards Publication 197 ("FIPS 197"):

https://csrc.nist.gov/publications/detail/fips/197/final

It is based entirely and solely on FIPS 197. The tests in tests/test_npaes.py use the full set of example vectors from Appendices A, B, and C of FIPS 197. npaes supports AES-128, AES-192, and AES-256.

Its sole dependency 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 src/npaes/__init__.py.

Installation

From PyPI:

pip install npaes

Or with uv:

uv add npaes

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 must be bytes and a multiple of 16 bytes long.
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'

Caution

This package is incomplete. While the raw encryption and decryption are fully tested using the FIPS 197 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.

Development

This project uses uv with the uv_build backend and a src/ layout.

uv sync                                         # install deps
uv run pytest                                   # tests + coverage
uv run ruff check && uv run ruff format --check # lint + format
uv run ty check                                 # type check
uv build                                        # build sdist + wheel

See CHANGELOG.md for release notes.

License

Apache-2.0. See LICENSE.

Metadata

Release files for npaes 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for npaes 0.4
File Size Uploaded Provenance
npaes-0.4.tar.gz 16.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for npaes 0.4
File Interpreter ABI Platform
npaes-0.4-py3-none-any.whl Python 3 none any Details

Total release size: 32.8 kB

Release files / npaes-0.4.tar.gz

Download URL npaes-0.4.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c7a72cbf81427d80207f9dc3d8cfee70e70a8e31fef9849f5279d924939b4167
BLAKE2b-256 checksum
How to use checksums
9e978bd939bc8ff04a189e4393ca6cd4e6df41530ae45199aaf142d5e9daff9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 19, 2026.

Transparency log

Release files / npaes-0.4-py3-none-any.whl

Download URL npaes-0.4-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f718658a18a9137698a089377f825a99fcb6d55e62a79a61fee317387a417165
BLAKE2b-256 checksum
How to use checksums
1c0df6913a929df787ade8a990fc54b2a313578c2d03c20611da9b3361e5ac15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 19, 2026.

Transparency log

Security for npaes 0.4

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for npaes-0.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 19, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page