Pack float32 payloads into quiet NaN float64 values
Project description
nancryption
nancryption encodes float32 values into float64 quiet-NaN bit patterns and decodes them back again. This is useful when you need to smuggle a 32-bit payload through a float64-only path while still tagging values as NaN.
Install
uv sync
Quick Start
import numpy as np
from nancryption import nancrypt, nandecrypt
payload = np.array([1.0, -2.5, np.pi], dtype=np.float32)
encoded = nancrypt(payload)
decoded = nandecrypt(encoded)
print(encoded.dtype) # float64
print(np.isnan(encoded).all()) # True
print(np.array_equal(decoded, payload)) # True
API
nancrypt(a: np.ndarray) -> np.ndarrayEncodes float32 payload bits into float64 quiet NaN values.nandecrypt(arr: np.ndarray) -> np.ndarrayRecovers the embedded float32 payload from encoded float64 values.
Development
Run tests:
uv run pytest
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
nancryption-0.1.0.tar.gz
(46.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nancryption-0.1.0.tar.gz.
File metadata
- Download URL: nancryption-0.1.0.tar.gz
- Upload date:
- Size: 46.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b7a231f47123c99b8ddaceb9e043f53532a4d5bebce671d69f3cd3a0bbcf44d
|
|
| MD5 |
2867918c358e6786c4d6ef2285df3bf3
|
|
| BLAKE2b-256 |
39fb02c7bdf19833a0a19d56734db364a53162916d213c3f71ebd0c0e0588208
|
File details
Details for the file nancryption-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nancryption-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6392124bf85c7a86c7e6c3c2aa5e9b70eef1fc31a840bef7ef4d9e6f9d82b3e
|
|
| MD5 |
beca9279b8b4031830777abb5fa6cc14
|
|
| BLAKE2b-256 |
282ead2c96180f85209a488afe5891fa8148b8794da6644f0202bc298101635c
|