Skip to main content

Python Cryptography

Project description

🔐 Python Cryptography

A blazing-fast cryptography library for Python, built on Rust.

Supports an extensive set of post-quantum digital signature algorithms (DSA) and key encapsulation mechanisms (KEM).

⚠️ Disclaimer: This library is intended for educational and research purposes only and is not recommended for production use.

⚡ Features

  • ✅ Dozens of NIST PQC candidates
  • 🦀 Rust core for speed and safety
  • 📦 Easy installation via pip

🧬 Supported Algorithms

💻 Classic

Cipher

  • ChaCha20Poly1305

  • XChaCha20Poly1305

Encoding

  • Base58

Hashing

  • Blake3

  • Keccak

  • Ripemd

Password Hashing

  • Argon2

  • Bcrypt

🛰️ Quantum

🛡️ KEM

  • Bike

  • ClassicMcEliece

  • Hqc

  • Kyber

  • MLKEM

  • NtruPrime

  • FrodoKem

✍️ DSA

  • Cross

  • Dilithium

  • Falcon

  • Mayo

  • MLDSA

  • Sphincs

  • Uov

❔ Examples

DSA Example

from kryptoon.quantum.dsa import Algorithm, KeyPair

# Step 1: Generate a new key pair (secret key and public key) using the MLDSA87 algorithm.
alicesk, alicepk = KeyPair(Algorithm.MLDSA.MLDSA87)

# Step 2: Restore (import) the secret key from its raw bytes.
# This simulates loading a saved secret key from storage.
secretkey = KeyPair(Algorithm.MLDSA.MLDSA87, secretkey=alicesk.secretkey)

# Step 3: Restore (import) the public key from its raw bytes.
# This simulates loading a saved public key from storage.
publickey = KeyPair(Algorithm.MLDSA.MLDSA87, publickey=alicepk.publickey)

# --- Alternative: Combined Key Import ---
# You can also restore both keys at once using a single call.
# This is useful when both the secret and public keys are available together.
secretkey, publickey = KeyPair(
    Algorithm.MLDSA.MLDSA87,
    secretkey=alicesk.secretkey,
    publickey=alicepk.publickey
)

# Step 4: Prepare the message to be signed (convert string to bytes).
message = "Hello".encode()

# Step 5: Sign the message using the secret key.
signature = secretkey.sign(message=message)

# Step 6: Verify the signature using the public key.
valid = publickey.verify(signature=signature, message=message)

# Step 7: Ensure that the signature is valid.
# If the verification fails, the program will raise an error.
assert valid, "Signature verification failed!"

# Step 8: Display the original message (decoded back to string).
print(f"Message:   [{message.decode()}]")

# Display the last 64 hex characters
print(f"Signature: [{signature.hex()[-64:]}]")
print(f"SecretKey: [{alicesk.secretkey.hex()[-64:]}]")
print(f"PublicKey: [{alicepk.publickey.hex()[-64:]}]")

KEM Example

from kryptoon.quantum.kem import Algorithm, KeyPair

# Step 1: Generate key pairs for Alice and Bob using MLKEM1024 algorithm
alicesk, alicepk = KeyPair(Algorithm.MLKEM.MLKEM1024)
_bobsk, _bobpk = KeyPair(Algorithm.MLKEM.MLKEM1024)

# --- Key Export ---
# Export Alice's keys as bytes (simulate saving keys)
alice_secret_bytes = alicesk.secretkey
alice_public_bytes = alicepk.publickey

# Export Bob's keys as bytes (simulate saving keys)
bob_secret_bytes = _bobsk.secretkey
bob_public_bytes = _bobpk.publickey

# --- Key Import ---
# Re-import Alice's keys from bytes
alicesk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=alice_secret_bytes)
alicepk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=alice_public_bytes)

# Re-import Bob's keys from bytes
bobsk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=bob_secret_bytes)
bobpk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=bob_public_bytes)

# Step 2: Bob encapsulates a shared secret using Alice's public key
bobss, bobct = alicepk_restored.encapsulate()

# Step 3: Alice decapsulates the ciphertext using her secret key to recover the shared secret
alicess = alicesk_restored.decapsulate(bobct)

# Step 4: Verify that both shared secrets match
assert alicess == bobss, "Shared secrets do not match!"

# Step 5: Print results
print(f"Alice's Shared Secret: [{alicess.hex()}]")
print(f"Bob's   Shared Secret: [{bobss.hex()}]")

# Display the last 64 hex characters
print(f"SecretKey:             [{alicesk_restored.secretkey.hex()[-64:]}]")
print(f"PublicKey:             [{alicepk_restored.publickey.hex()[-64:]}]")

📦 Install

pip install kryptoon

🥳 Enjoy!

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

kryptoon-2026.1.3.tar.gz (16.4 kB view details)

Uploaded Source

Built Distributions

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

kryptoon-2026.1.3-cp314-cp314-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.14Windows x86-64

kryptoon-2026.1.3-cp314-cp314-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.3-cp314-cp314-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

kryptoon-2026.1.3-cp313-cp313-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.13Windows x86-64

kryptoon-2026.1.3-cp313-cp313-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.3-cp313-cp313-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kryptoon-2026.1.3-cp312-cp312-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.12Windows x86-64

kryptoon-2026.1.3-cp312-cp312-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.3-cp312-cp312-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kryptoon-2026.1.3-cp311-cp311-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.11Windows x86-64

kryptoon-2026.1.3-cp311-cp311-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.3-cp311-cp311-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kryptoon-2026.1.3-cp310-cp310-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.10Windows x86-64

kryptoon-2026.1.3-cp310-cp310-manylinux_2_38_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ x86-64

kryptoon-2026.1.3-cp310-cp310-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file kryptoon-2026.1.3.tar.gz.

File metadata

  • Download URL: kryptoon-2026.1.3.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for kryptoon-2026.1.3.tar.gz
Algorithm Hash digest
SHA256 28195300efef988539574c56438e818539de54fdde2c184aefe0ebb912aa596c
MD5 cea4f57ebc709a12d1a10a0d11ef640f
BLAKE2b-256 9cfdb47723b00da21227bd43bf6289a282e11323fbffc76cafb6640b09b03141

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0340ae568259d3c52864becf73226dabe9a3642064f0e2b05d5f9f9264cd7b5a
MD5 dfee05d1c7b70a2a9b988b6f409dfb37
BLAKE2b-256 c049dcd1ba25c8cc02ea327b3fff87cbce2766540d1481c2db45937780f3fd23

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 3491630f28f2b4879954391ef4c4ffd0da21e34dd30cc75aa7fdb43ffd856bc4
MD5 62595badaf38f9e76fc1818e890e1af9
BLAKE2b-256 e443bc79f1e63871fdca6229b2790da7021461538a1ffb02219e108c8d618e0d

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9889b49abf197f98887339446c712dfdd0d53dc250acb21143c04293f208513f
MD5 8b708c01fb11a0ff644c577d0180af60
BLAKE2b-256 be15df9488d96e7f4cea22558bf720c27dfd9da20b985c7820bf42e13f2d2593

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 351f9a9bbca2baf8b270a47db0419045033dc8ce0bf86f899beffbea2e4ae6bd
MD5 2a26ecbf3268d3195a27c5e64b1790b1
BLAKE2b-256 c21e1849c85b82cfe1a8398185054219db336dd8810163f2177c29073a54067a

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 15ca5e8748542a86eb3a2590bb860d9c94a0ecc54e307e67f05ec4c6ace04758
MD5 9141e24961167606ceed938d28dfe9c2
BLAKE2b-256 6dd9bf1e85bc057a14db488670e9fcadd209587ef2bd5f742ee36c4cc02fc314

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 49e16ed65bb6baa9af744e7c9be273b6db3a1aa8622e0275676c6f2369860340
MD5 17c36d12905744d16796a3fb9ef26515
BLAKE2b-256 623427f0f46c352225ca3ce772f5bbc505610b87d1f5e8149780c5a7be586743

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a99feed2b8667da0be7e1cdd12ed53ba45a98e8055bc7e44a01a8685aa0dfe0b
MD5 031a2bb43d30a11c112a91823b88552f
BLAKE2b-256 41c0882c5184a02295f15fc53eaed24be751982f04dfd46976016b29550c028b

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 0ef334666ef1cabaec2d1c68c04984f79d11ec69179813621ea783087cc90282
MD5 e802e58e8a2bc2a9116120819f49c8d3
BLAKE2b-256 98e1f37b4b014ae8eb482c2e52e8e442df872302edcfb454bae5ace8d9bb7e46

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5967551af31daa502f440005e9eabbec4712b2aff9fdbb36dda6f9c32202841f
MD5 0b5362b536d2088feb54df41ddc51ce4
BLAKE2b-256 7d85cc755c1e8caee64ba334bcf5fce4e74dc215cd3fe1ae97cda0445e71f26d

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9bb0eb16dd7df93630a0d4a0aee4d44767d0469c3714a10db45626f985388f24
MD5 af106575752398ac3ce16037ba7216dd
BLAKE2b-256 417f7a02e77bf66564d31409088756dd84e50762e17e7c20a1787fe7a5b5675a

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 31c162bd9d2b5d2e784f4e67db95102117abf821011c54e2b08b7c3bba549a4b
MD5 88093571776edcb655d38576bd4ffe3d
BLAKE2b-256 40838a9e9eae1a8322cb6814726591c154df0dae06ae4418ac783369e2cc3a2a

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c55e736c5213a1944f1f33f10ee495a215dc95c255aab65cd28cd741e7b003ba
MD5 0e0570a1acf7d8785e07144e4d0e9328
BLAKE2b-256 afc005b4ceb6d48622c8a10d4a0012ffeae90ea07c23ad862e3d391f41de043d

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fbf83720880add5c090476bf45c89603abec4f484c965c108f1b636769a69674
MD5 092c162e4043d82d9808d6628d9ed7df
BLAKE2b-256 3dde47d98e40444763cb576000f386a8df6ec5c35888d0dfa3bf71d7063cbe26

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 416aa05899e89054084ccb4c144949359ec37f3491f43c8970922680ec323c59
MD5 a81b2ff2c64a7f58026f8cf803d3b56d
BLAKE2b-256 b1d5f0c6d68451226b5b3e5d7093aa868adb29425fbdcd158ffc2af34fcbb620

See more details on using hashes here.

File details

Details for the file kryptoon-2026.1.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kryptoon-2026.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f3226e9759b120f68935bb3e8ae00b307dbacc4dfeb3c6467d8e0f7a6440bdf
MD5 8f23e9a7176096324a4f8c9b6e7b4223
BLAKE2b-256 b70d80a11e743790ddf83c51a939cfb52d8017a250b95d4e7201085290986f2d

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