Skip to main content

🛡️ Iki-Protect

PyPI version License: Apache-2.0

One tool. Every data-protection primitive you'll ever need. Find PII and secrets, hide them, hash things, encrypt things, sign things, and issue JWTs — from a single CLI command or a single Python object. No servers, no accounts, no external services required.

Image_Cover

pip install ikiprotect
from ikiprotect import IkiProtect
protect = IkiProtect()

That's it — everything below is one method call or one CLI command away.


🧰 Full strategy inventory

🔐 Encryption strategies

  • aes-256-gcm
  • aes-192-gcm
  • aes-128-gcm
  • aes-256-ccm
  • aes-192-ccm
  • aes-128-ccm
  • aes-256-gcm-siv
  • aes-siv
  • ascon-128
  • ascon-128a
  • chacha20-poly1305
  • xsalsa20-poly1305
  • xchacha20-poly1305

#️⃣ Fast hash strategies

  • md5
  • sha1
  • sha224
  • sha256
  • sha384
  • sha512
  • sha512-224
  • sha512-256
  • sha3-224
  • sha3-256
  • sha3-384
  • sha3-512
  • shake128
  • shake256
  • blake2b
  • blake2s
  • blake3
  • ripemd160
  • crc16
  • crc32
  • crc64
  • adler32
  • xxh32
  • xxh64
  • xxh3-64
  • xxh3-128

🧠 HMAC strategies

  • hmac-sha224
  • hmac-sha256
  • hmac-sha384
  • hmac-sha512
  • hmac-sha512-224
  • hmac-sha512-256
  • hmac-sha3-224
  • hmac-sha3-256
  • hmac-sha3-384
  • hmac-sha3-512
  • hmac-blake2b
  • hmac-blake2s

🔑 Password-hash / KDF strategies

  • argon2id
  • argon2i
  • argon2d
  • bcrypt
  • scrypt
  • pbkdf2-sha224
  • pbkdf2-sha256
  • pbkdf2-sha384
  • pbkdf2-sha512
  • pbkdf2-sha512-224
  • pbkdf2-sha512-256

✍️ Signature strategies

  • ed25519
  • ed448
  • rsa-pss
  • rsa-pkcs1v15
  • ecdsa-p224
  • ecdsa-p256
  • ecdsa-p384
  • ecdsa-p521
  • secp256k1
  • ml-dsa-44
  • ml-dsa-65
  • ml-dsa-87
  • falcon512
  • falcon1024
  • sphincs-sha2

🪪 JWT algorithms

  • HS256, HS384, HS512
  • RS256, RS384, RS512
  • PS256, PS384, PS512
  • ES256, ES384, ES512
  • EdDSA

🚀 Why people reach for this

  • 🔍 Finds what shouldn't be there — emails, credit cards, IBANs, SSNs, IP addresses, and 12 different flavors of leaked API key/secret, in any text or file.
  • 🙈 Hides it your way — full redaction, partial masking (j***e@example.com), or deterministic tokenization that stays consistent every time.
  • 🔐 Locks it down — 11 modern AEAD ciphers, layered/chained encryption, envelope (DEK/KEK) encryption with key rotation, chunked encryption for huge files, and public-key encryption (Hybrid KEM / HPKE).
  • #️⃣ Hashes anything — fast digests for checksums, keyed HMACs for integrity, and slow Argon2/PBKDF2 KDFs for passwords — done right by default.
  • ✍️ Proves authenticity — Ed25519, RSA-PSS, and ECDSA signatures; full JWT encode/decode/verify across 11 algorithms.
  • 🔑 Manages your keys — generate keypairs, derive keys from passphrases, resolve keys from env vars/files, split a secret into shares and recombine it later.
  • 🖥️ CLI or 🐍 Python — your choice — every capability works as a terminal command and as a plain Python method call through the IkiProtect facade.

🧩 The complete feature set

🔍 Find sensitive data — detect

Scans a string, file, or an entire folder and tells you exactly what it found and where.

Category What it catches
PII Emails, phone numbers, US Social Security numbers, IPv4 addresses, credit card numbers, IBANs
Secrets AWS keys, GCP keys, GitHub tokens (classic + fine-grained), GitLab tokens, Slack tokens, Stripe keys, OpenAI keys, Twilio keys, NPM tokens, PEM private-key blocks, JWTs
  • Group findings with easy shorthands: --types pii, --types secrets, or both.
  • Overlapping matches are automatically de-duplicated so you don't get double hits on the same text.
  • Scan a whole repo with --recursive, respect a .ikiprotectignore file, and fail your CI pipeline with --fail-on if anything's found.
  • Extendable with your own detectors via a plugin system.
ikiprotect detect notes.txt --format json
findings = protect.detect("email me at a@b.com", types="pii,secrets")

🙈 Hide sensitive data — mask

Once something's found, replace it in place or write a cleaned copy.

Strategy Example Best for
redact john@example.com[REDACTED] Logs, tickets, anything shared externally
partial john@example.comj****************m Support screenshots, debugging
tokenize john@example.comV-ntuFR9wvlZhRp- Analytics/pseudonymization — same input always gives the same token
ikiprotect mask notes.txt --types pii,secrets --strategy partial
ikiprotect mask foo.txt --strategy tokenize --key-ref file:./token_key.bin
ikiprotect mask notes.txt --types pii --strategy redact --include-unredacted

When --include-unredacted is used, the CLI prints JSON with both the original and masked versions:

{
	"unredacted_text": "Contact john.doe@example.com for details",
	"masked_text": "Contact [REDACTED] for details"
}

#️⃣ Hash anything — hash

One command covers everything from "checksum a file" to "store a password correctly."

  • General-purpose digests: SHA-256, SHA-512, SHA3-256, SHA3-512, BLAKE2b, BLAKE2s, BLAKE3 (plus keyed and extendable-output BLAKE3 modes), CRC32
  • Keyed MACs (integrity/authenticity): HMAC-SHA256, HMAC-SHA512
  • Password-grade KDFs (slow & salted on purpose): Argon2id, Argon2i, Argon2d, PBKDF2-SHA256, PBKDF2-SHA512 — with Argon2's cost parameters tunable via environment variables for production hardening
  • Verifying a password hash auto-detects which algorithm produced it, so you don't have to remember or store that separately
echo -n "correct horse battery staple" | ikiprotect hash --algo argon2id
pw_hash = protect.hash_password("correct horse battery staple")
protect.verify_password(pw_hash, "correct horse battery staple")

🔐 Encrypt anything — encrypt / decrypt

From a quick one-off secret to a full key-management pipeline.

  • 11 authenticated ciphers: AES-256-GCM, AES-192-GCM, AES-128-GCM, AES-256-CCM, AES-192-CCM, AES-128-CCM, AES-256-GCM-SIV, AES-SIV, Ascon-128, Ascon-128a, XSalsa20-Poly1305, ChaCha20-Poly1305, and XChaCha20-Poly1305
  • Self-describing ciphertext — the algorithm and nonce length travel with the ciphertext, so decrypt just works without extra bookkeeping
  • Layered encryption — chain multiple algorithms together for defense-in-depth
  • Envelope encryption (DEK/KEK) — generate a fresh data key per message, wrap it under a master key, and rotate the master key later without re-encrypting the payload
  • Chunked/streaming encryption — handles multi-gigabyte files in fixed-size, independently-authenticated chunks
  • Public-key encryption — Hybrid KEM (X25519) and a minimal HPKE-compatible mode, so you can encrypt to someone's public key with no shared secret needed
  • Built-in KMS simulator — generate and unwrap data keys the same way you would with AWS KMS, entirely offline (with a placeholder ready for a real AWS KMS integration)
ikiprotect encrypt secret.txt --key-ref env:MY_KEY -o secret.enc
ikiprotect encrypt secret.txt --envelope --key-ref env:MY_KEK -o secret.enc
ikiprotect encrypt rewrap secret.enc --old-key-ref env:OLD_KEK --new-key-ref env:NEW_KEK -o secret.rewrapped
ciphertext = protect.encrypt(b"secret data", key)
envelope = protect.envelope_encrypt(kek, b"secret data", ["aes-256-gcm"])
encap, shared_key = protect.hybrid_encapsulate(recipient_public_key)

✍️ Prove authenticity — sign / verify-signature, jwt

  • Digital signatures: Ed25519, RSA-PSS, ECDSA (P-256, P-384, P-521) — sign a release artifact, verify it came from you
  • JWTs: encode, decode, and verify across HS256/384/512, RS256/384/512, PS256/384/512, ES256/384/512, and EdDSA, with issuer/audience/leeway checks built in
ikiprotect generate-keypair --algo ed25519 -o ./keys
ikiprotect sign release.tar.gz --algo ed25519 --private-key ./keys/ed25519_private.key -o release.sig
ikiprotect jwt encode claims.json --algo HS256 --key-ref env:JWT_SECRET
priv, pub = protect.generate_keypair("ed25519")
signature = protect.sign(b"message", priv)
token = protect.jwt_encode({"sub": "1234"}, b"hs256-secret", "HS256")

🔑 Manage your keys

  • Generate keypairs (Ed25519, RSA, ECDSA P-256/384/521) with one command
  • Derive an encryption key from a human passphrase (SHA-256, PBKDF2, or Argon2id)
  • Resolve keys from env:VAR_NAME, file:path, or a raw path — with file-permission checks so you don't accidentally use a world-readable key
  • Split a secret into N shares with a K-of-N recovery threshold, then recombine them later (true Shamir secret sharing, or an XOR fallback)
ikiprotect keys split secret.bin --n 5 --k 3 -o shares.json
ikiprotect keys combine shares.json -o recovered.bin
shares = protect.split_secret(secret_bytes, n=5, k=3)
recovered = protect.combine_shares(shares)

📄 Works with structured files, too

Beyond plain text/log files, Iki-Protect can target a single field inside one JSON or YAML config file by dot-path (e.g. database.password) instead of scanning/replacing the whole document.


🖥️ CLI or 🐍 Python — everything, either way

Every feature above works two ways:

  1. From the terminal, via the ikiprotect command (see the command table and examples above).
  2. From Python, via one object: IkiProtect from iki_protect.facade. No need to know which internal class implements "aes-256-gcm" or "argon2id" — just call the method.
from iki_protect.facade import IkiProtect

protect = IkiProtect()

# Detect & mask
findings = protect.detect("email me at a@b.com", types="pii,secrets")
masked = protect.mask("email me at a@b.com")

# Hashing
digest = protect.hash(b"data", algorithm="sha256")
pw_hash = protect.hash_password("correct horse battery staple")
protect.verify_password(pw_hash, "correct horse battery staple")

# Encryption
key = protect.derive_passphrase_key("my passphrase")
ciphertext = protect.encrypt(b"secret data", key)
plaintext = protect.decrypt(ciphertext, key)

# Keys, signing, JWT
priv, pub = protect.generate_keypair("ed25519")
signature = protect.sign(b"message", priv)
protect.verify_signature(signature, b"message", pub)

token = protect.jwt_encode({"sub": "1234"}, b"hs256-secret", "HS256")
claims = protect.jwt_verify(token, b"hs256-secret", "HS256")

Want the underlying strategy classes instead of the facade? iki_protect.api re-exports every building block flat, for from iki_protect.api import Aes256GcmStrategy style imports. See examples/example_usage.py for a full end-to-end walkthrough of every single feature in one runnable script.


📦 Project layout

src/iki_protect/
├── cli/                    # Typer-based CLI commands (detect, mask, hash, encrypt, decrypt, sign, jwt, keys)
├── content/                 # Plain text, JSON, YAML readers (one file at a time)
├── core/
│   ├── detectors/           # Regex + checksum-based PII/secret detectors, plugin registry
│   ├── keys/                 # Key resolution, generation (Ed25519/RSA/ECDSA), passphrase derivation, KMS, secret sharing
│   └── strategies/
│       ├── masking/          # Redact / partial-mask / tokenize transforms
│       ├── hashing/            # Fast hashes, HKDF, Argon2/PBKDF2 slow hashes
│       ├── encryption/          # AEAD ciphers, layered/envelope/chunked encryption, Hybrid KEM, HPKE
│       ├── signing/              # Ed25519 / RSA-PSS / ECDSA
│       └── jwt/                    # JWT encode/decode/verify
├── api.py                   # Flat re-export of every public symbol
└── facade.py                 # `IkiProtect` — one object, name-driven method for every feature
examples/example_usage.py    # Runnable end-to-end demo of the whole feature set
tests/                       # Unit + security test suites

🛠️ Installation

pip install ikiprotect

Requires Python ≥ 3.9. Core dependencies (installed automatically): typer, rich, cryptography, blake3, argon2-cffi, PyYAML.

Working on the source directly instead of installing from PyPI:

git clone <this-repo>
cd iki-protect
pip install -e ".[dev]"

⚡ Quick examples

# Detect and mask PII/secrets in a file
ikiprotect detect notes.txt --format json
ikiprotect mask notes.txt --types pii,secrets --strategy partial
ikiprotect mask notes.txt --types pii --strategy redact --include-unredacted

# Hash a value with Argon2id (password-grade)
echo -n "correct horse battery staple" | ikiprotect hash --algo argon2id

# Encrypt/decrypt a file (key-ref based)
ikiprotect encrypt secret.txt --key-ref env:MY_KEY -o secret.enc
ikiprotect decrypt secret.enc --key-ref env:MY_KEY -o secret.txt

# Envelope mode (DEK/KEK): generate a random DEK, wrap under KEK
ikiprotect encrypt secret.txt --envelope --key-ref env:MY_KEK -o secret.enc
# Rotate the KEK that wraps the DEK without re-encrypting payload
ikiprotect encrypt rewrap secret.enc --old-key-ref env:OLD_KEK --new-key-ref env:NEW_KEK -o secret.rewrapped

# Recursive scan with CI gate
ikiprotect detect . --recursive --format ndjson --fail-on 1

# Tokenize values deterministically (requires keyed strategy)
ikiprotect mask foo.txt --strategy tokenize --key-ref file:./token_key.bin

# Secret sharing (split/combine)
ikiprotect keys split secret.bin --n 5 --k 3 -o shares.json
ikiprotect keys combine shares.json -o recovered.bin

# Sign and verify a release artifact
ikiprotect generate-keypair --algo ed25519 -o ./keys
ikiprotect sign release.tar.gz --algo ed25519 --private-key ./keys/ed25519_private.key -o release.sig
ikiprotect verify-signature release.tar.gz release.sig --algo ed25519 --public-key ./keys/ed25519_public.key

# JWT
ikiprotect jwt encode claims.json --algo HS256 --key-ref env:JWT_SECRET
ikiprotect jwt verify "<token>" --algo HS256 --key-ref env:JWT_SECRET

Before using --passphrase/sha256 defaults for anything real, read AUDIT.md — item C1/C2 covers weak defaults you should override (--kdf argon2id and a real --salt).

🧠 Design principles

  • Every command operates on one value/file at a time — this is not a dataset/batch tool.
  • Ciphertext is self-describing: a version byte + implied nonce length means decrypt never needs the nonce or algorithm re-supplied separately.
  • Two distinct key-loading paths exist on purpose: KeyManager.resolve() normalizes any input to a 32-byte key; KeyManager.load_raw() returns exact bytes for algorithms that need precise key material.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ikiprotect-1.1.1.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

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

ikiprotect-1.1.1-py3-none-any.whl (62.2 kB view details)

Uploaded Python 3

File details

Details for the file ikiprotect-1.1.1.tar.gz.

File metadata

  • Download URL: ikiprotect-1.1.1.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ikiprotect-1.1.1.tar.gz
Algorithm Hash digest
SHA256 395eb334a6e58bf5b9172e11f16285b2a6a72369e9d6dc5b751a6077865afb5d
MD5 da1236e87c78c5f78bf07015d89def17
BLAKE2b-256 7406e4efe279603334c1c4f9085f49533614e05ab0ca8dafdc2258ad1ef96f3d

See more details on using hashes here.

File details

Details for the file ikiprotect-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: ikiprotect-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 62.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ikiprotect-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2480991abe192bdccaa8c01ee5089f7e77a1c1c674497166d024d4f23922ca59
MD5 f236ec712d35c78e0ad80c50457ad1a9
BLAKE2b-256 c93e67c331776785d87a43449bb7ac98260663410072efc2f02194eaf6ec53b0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

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