# bnlucas/obfuskey architecture

> Architecture diagram of the GitHub repository bnlucas/obfuskey, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bnlucas/obfuskey
- Repository: https://github.com/bnlucas/obfuskey

## Overview

Obfuskey is a Python library for reversible integer-to-key obfuscation; Obfusbit adds schema-defined bit packing, optional obfuscation, and byte conversion. The graph shows the documented workflows and source-supported calls. The README describes predefined/custom alphabets and multiplier configuration; details of unsampled runtime code are not inferred beyond those documented capabilities.

Main entry points: [`obfuskey/_obfusbit.py`](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfusbit.py) (Pack and unpack), [`obfuskey/_obfuskey.py`](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfuskey.py) (Key generation), [`obfuskey/__init__.py`](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/__init__.py) (Public API), [`obfuskey/_math.py`](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_math.py) (Prime and modular math)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_packing["Schema Packing"]
  node_schema["Schema validation"]
  node_obfusbit["Pack and unpack<br/>[_obfusbit.py]"]
  node_byte_conversion["Byte conversion<br/>[_obfusbit.py]"]
end

subgraph group_keys["Key Obfuscation"]
  node_obfuskey["Key generation<br/>[_obfuskey.py]"]
  node_alphabets["Alphabet constants<br/>[alphabets.py]"]
end

subgraph group_support["Encoding and Math"]
  node_utilities["Base conversion and primes<br/>[utils.py]"]
  node_math["Prime and modular math<br/>[_math.py]"]
end

node_consumer(("Library consumer"))
node_public_api["Public API<br/>[__init__.py]"]
node_gmpy2["Optional gmpy2"]

node_consumer -->|"imports"| node_public_api
node_consumer -->|"packs or unpacks"| node_obfusbit
node_consumer -->|"encodes or decodes"| node_obfuskey
node_public_api -->|"exports"| node_obfusbit
node_public_api -->|"exports"| node_schema
node_public_api -->|"exports"| node_obfuskey
node_obfusbit -->|"validates schema and values"| node_schema
node_obfusbit -->|"obfuscates or reverses"| node_obfuskey
node_obfusbit -->|"converts packed integers"| node_byte_conversion
node_obfuskey -->|"encodes, decodes, generates prime"| node_utilities
node_utilities -->|"finds next prime"| node_math
node_obfuskey -->|"computes modular inverse"| node_math
node_math -.->|"uses for large primes"| node_gmpy2

click node_public_api "https://github.com/bnlucas/obfuskey/blob/main/obfuskey/__init__.py"
click node_schema "https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfusbit_schema.py"
click node_obfusbit "https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfusbit.py"
click node_byte_conversion "https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfusbit.py"
click node_obfuskey "https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfuskey.py"
click node_alphabets "https://github.com/bnlucas/obfuskey/blob/main/obfuskey/alphabets.py"
click node_utilities "https://github.com/bnlucas/obfuskey/blob/main/obfuskey/utils.py"
click node_math "https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_math.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_schema,node_obfusbit,node_byte_conversion toneBlue
class node_obfuskey,node_alphabets toneAmber
class node_utilities,node_math,node_public_api toneMint
class node_consumer,node_gmpy2 toneIndigo
```

## Components

### Schema Packing

- [Schema validation](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfusbit_schema.py): `obfuskey/_obfusbit_schema.py`
- [Pack and unpack](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfusbit.py): `obfuskey/_obfusbit.py`
- [Byte conversion](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfusbit.py): `obfuskey/_obfusbit.py`

### Key Obfuscation

- [Key generation](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_obfuskey.py): `obfuskey/_obfuskey.py`
- [Alphabet constants](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/alphabets.py): `obfuskey/alphabets.py`

### Encoding and Math

- [Base conversion and primes](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/utils.py): `obfuskey/utils.py`
- [Prime and modular math](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/_math.py): `obfuskey/_math.py`

### Other components

- **Library consumer**
- [Public API](https://github.com/bnlucas/obfuskey/blob/main/obfuskey/__init__.py): `obfuskey/__init__.py`
- **Optional gmpy2**

## Connections

- Library consumer → Public API: imports
- Library consumer → Pack and unpack: packs or unpacks
- Library consumer → Key generation: encodes or decodes
- Public API → Pack and unpack: exports
- Public API → Schema validation: exports
- Public API → Key generation: exports
- Pack and unpack → Schema validation: validates schema and values
- Pack and unpack → Key generation: obfuscates or reverses
- Pack and unpack → Byte conversion: converts packed integers
- Key generation → Base conversion and primes: encodes, decodes, generates prime
- Base conversion and primes → Prime and modular math: finds next prime
- Key generation → Prime and modular math: computes modular inverse
- Prime and modular math → Optional gmpy2: uses for large primes
