Skip to main content

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.ndarray Encodes float32 payload bits into float64 quiet NaN values.
  • nandecrypt(arr: np.ndarray) -> np.ndarray Recovers the embedded float32 payload from encoded float64 values.

Development

Run tests:

uv run pytest

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nancryption-0.1.0-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

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

Hashes for nancryption-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b7a231f47123c99b8ddaceb9e043f53532a4d5bebce671d69f3cd3a0bbcf44d
MD5 2867918c358e6786c4d6ef2285df3bf3
BLAKE2b-256 39fb02c7bdf19833a0a19d56734db364a53162916d213c3f71ebd0c0e0588208

See more details on using hashes here.

File details

Details for the file nancryption-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nancryption-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6392124bf85c7a86c7e6c3c2aa5e9b70eef1fc31a840bef7ef4d9e6f9d82b3e
MD5 beca9279b8b4031830777abb5fa6cc14
BLAKE2b-256 282ead2c96180f85209a488afe5891fa8148b8794da6644f0202bc298101635c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page