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.1.tar.gz (16.8 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.1-cp314-cp314-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.14Windows x86-64

kryptoon-2026.1.1-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.1-cp314-cp314-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

kryptoon-2026.1.1-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.1-cp313-cp313-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

kryptoon-2026.1.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

kryptoon-2026.1.1-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.1-cp311-cp311-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

kryptoon-2026.1.1-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.1-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.1.tar.gz.

File metadata

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

File hashes

Hashes for kryptoon-2026.1.1.tar.gz
Algorithm Hash digest
SHA256 8b720c70aa5ccdebd7ca5cfbb8e0265d4bf3f78b42e04daeb391fdf47400e0d1
MD5 b0ef964d1bbc6f589555a07a061b3c3a
BLAKE2b-256 fbf23edbcfd46dc6bae4d597cf371a9d5d0a2a34b70996b390eea45614ddc179

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 23f8c8ea990d30ec1da1498cba14481021f90002826b87c4557c416b240308d9
MD5 a99e0e248551fbfb2b359e7cbbe70bdd
BLAKE2b-256 18497c724d6748b98d83f7932679296aa7ace3c04171f1cfd2b565e085d4e670

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 6a592be726c7064ec5cd1dafda7430df361cedfc05b69223c9389c073d6fdc19
MD5 64e245f6c6c2f0abd9b49eb1f53d2775
BLAKE2b-256 d86cde64333d289b0730780fc789a43f26c6aee89168da723389e2b40d8690cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0bf60c0b87035aa51ae2a304360f0d980ecc8bf2d8aaf7417f1b4a40aacac5b
MD5 d0556e69071d7525f0725552c95dc920
BLAKE2b-256 7dec3e388272ece2b39442606b4e026e2c8741136977da5c144dc3e63e55dc8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 eaa96829d59d4cbde88fc57a764ebb85219bf6bd9659ab239d086055347dd572
MD5 f0a72d11d5f5ec559e19492f75c0f2d8
BLAKE2b-256 ee68179f2db94302ddc6108a3a725ce2d77fe9a06144461553dd1987361a9c33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 7f8b506acaf3d67e3b38807b8c35d4a81200aec34598fe824923e6fb008f4906
MD5 62d0223fd60faefe7a949e910acd96d0
BLAKE2b-256 2c7ede1a932116fff1f89c8b1f09569f2df2a5e3e074b91e931d9a44fe9d7fe9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4fa46c1fc671c6741edfa610777196729befcfcb521c51169c3a424dccfad9d3
MD5 9cac38fc2d2072c116f9a7045577726a
BLAKE2b-256 00019f4bb9e301a9d72339cfba819bc10d9beba07a61ddaac83e92383ff27eae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f30bd6858ae0dc1a9982d2252376749f742a7121fec48d93a7503246b38b1430
MD5 75b8d17a62c53b5415a0f906a1597b72
BLAKE2b-256 92eff5613958c05886bde65f37d8e40594d78d511ff662135238c4c4bf5f8390

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 94773f66db15b4faa19ff52fd0b23dd6abaf644af8ebd8fe51a6687d64771666
MD5 af4acf91ff403f1b3bd19e785be02de6
BLAKE2b-256 25599227f86033c961022aac7d01492c167e6bb6b0e58365db7abc72be55a901

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8aead508c2c59c59a0dc1e80aad74d110825d3ed34f4225f7675724e3c039269
MD5 60cf1aff722dc32ddccb37bf3119266a
BLAKE2b-256 e8848b14d1ff4c68f224c0860d08666e096ab2b9d3b78c7dedd55a36544cec78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 122cfa691940f23f8e86cd12ae09517a9f452a3fe769d9c1293ddc4a57b94428
MD5 993798cdf8cb319e9e7591c755e48502
BLAKE2b-256 c04d4a7e32e13e4a62f8a1e834487e3cb9282b7a832dba443ce0d56050d8a4fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 2b852f334419acaf0c1ad07a32ecfd97da7d591edebfd08e565691b387391887
MD5 3cd92146cba888d62e961d33c6a1fb28
BLAKE2b-256 4ca2c5eebdcca87c516dc3200cd86f2e5656f8cc2c8f2d0153affae3b02f3a6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c7472a3c5a05b3bde4b2c6cfd0c3d1af45de8cfc84455133f42e6952514704b
MD5 4010dca47cfc2f61afa07a2daa4ac25d
BLAKE2b-256 8a03740b451ecd55203c2b4f67fbf73558072b960425e209f1d73ff07db254ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c45c053ecca77be320f89cb6ca83fe0ef881dfcbc4101faeb9ce139791395870
MD5 e948bf2e723d6aecc9802779dd56e86a
BLAKE2b-256 bc0677cead430426a03c93a3ae831e2b7487004577862d7f53d07e0252b8342a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 208f1d01eedfa12b575b0db41a84f5dfa984bf329e21836e0c1de6133578a862
MD5 66a296f206a206b3a0ac9e66ea73681d
BLAKE2b-256 c7015bd71f6ee20805f8c4196c6b972c392f73c0fb78f6259b4e9b2c51e8cc9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kryptoon-2026.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 551b715878c367e8475e71066e66f6ed5ee25304a7687105375f46c86967f7d8
MD5 7847601160a8a5978f11d6cb22582efe
BLAKE2b-256 9a522e82740805f4832d5fae0e87cf1a625f081f9357672f46d568cd0c74390e

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